How to show a string as html content in a web form

I am trying to get an html document that will be displayed on my web page, now the content comes from the database as a string. Now I know that there is a way to do this in win forms using Browser.DocumentText. But how to do it in a web form?

I tried setting the innerHTML property for the div inside "OnRowCommand", "OnRowCommand" is inside the update panel. When I move the Div outside the panel, say, just below the body, it looks good.

+6
source share
4 answers

Add a literal control to the aspx file and in the codebehind setting

Literal1.Text=data_from_DB;

+6
source

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

Or maybe define a public line inside your page and then use it directly in html like:

 <%= strSomeString %> 
+8
source

Try the following:

html code:

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

Code behind:

  webcontent.InnerHtml = FromDBstring; 
+2
source

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

0
source

Source: https://habr.com/ru/post/902730/


All Articles