.NET: How to display a string in HTML format?

I have HTML markup written as a string in my database. How to convert them and view them as formatted HTML markup? I tried Server.HtmlEncode (), HttpUtility.HtmlEncode () without success

+3
source share
2 answers

This is something like what you need: Encode and display HTML-DotNetSlackers

+2
source

It looks like you are trying to simply output HTML content to a page through ASP.NET. If not, I apologize.

, ASP.NET Literal . , HTML- HTML , , .

<!-- Put into your page where you want it all to happen. -->

<asp:Literal id="labelLiteral" runat="server"/>

...

/* Put into your server code. */

// This would be where your DB content comes from.
String content = "<strong>Some Label:</strong>";

// Wrap the content in a label. Obviously you'll want better format.
String output = String.Format("<label>{0}</label>", content);

// Push the output into the literal.
labelLiteral.Text = output;

, .

0

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


All Articles