Navyseal
Navyseal

Reputation: 901

how do I show a string as html content in web form

I am trying to retrieve a html document to show in my web page, now the content comes from database as a string. Now I know there is a way to do this in win forms using Browser.DocumentText. But how do I do this in web form?

I tried the setting the innerHTML property for a div inside of the "OnRowCommand", the "OnRowCommand" happens to be inside an update panel. When I move the Div outside the panel, say to just below the body, it renders well.

Upvotes: 7

Views: 15176

Answers (4)

tareq_moinul
tareq_moinul

Reputation: 109

Try this one:

html code:

 <div id="webcontent" runat="server">
 </div>

Code behind:

  webcontent.InnerHtml = FromDBstring;

Upvotes: 2

Issa Qandil
Issa Qandil

Reputation: 1238

Well there are many ways to do this, you can use a label, literal Controls.

Or maybe defining a public string within your page then use it directly in your html as:

<%= strSomeString %>

Upvotes: 9

Elyor
Elyor

Reputation: 865

Write up for Mvc app Html.Raw('html tages') or MvcHtmlString.Create('html tages') and for web form HttpUtility.HtmlEncode('html tages')

Upvotes: 0

Nitesh
Nitesh

Reputation: 2337

Add a literal control in aspx file and in codebehind set

Literal1.Text=data_from_DB;

Upvotes: 7

Related Questions