tags:

views:

37

answers:

2

Hi, I have in my DB a HTML markup written as a strings. How to convert them and view as a formatted HTML markup ? I tried Server.HtmlEncode(), HttpUtility.HtmlEncode() with no success

+1  A: 

Is this something like what you are after: Encode and Display HTML - DotNetSlackers

daft
A: 

It sounds like you're trying to simply output HTML content to a page through ASP.NET. If this is not the case, then I apologize.

You probably want to inject into an ASP.NET Literal control, as opposed to setting a label. If you need the DB HTML put into a label, wrap the label around the DB's content on the server and then fill to literal.

<!-- 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;

I hope this helps.

Lance May