ethem
ethem

Reputation: 2908

how to render HTML entities to normal character into ASP literal control?

how there, I've these codes in my DATABASE in other words it's HTML. I tried these stuff:

<div runat="server" id="div1" visible="false"> 
    <asp:Literal ID="literal1" runat="server" Text="" />
</div>

I tried in C# code behind:

div1.InnerText = contents; 
div1.InnerHtml = contents
literal1.Text  = contents;

But is still doesn't render well. I displays the original values in stead of a table and cells and columns. colours etc. etc....

What am I missing?

All these HTML's are in DABASE.Column e.g. column "Contents" e.g.

"& lt;p class=& quot;MsoNormal&quot; style= &quot;color: #339966;&quot;&gt;&lt"

;&quot ;&gt ;&lt ;strong &gt ;&l

ot; &gt ;&amp ;nbsp; &lt ;/span &gt;&lt ;/p &gt;

Can someone please advice? what I'm I misssing?

I've put (spaces between & and gt above code otherwise it was not showing in stackoverflow.) The HTML sysntaxs are correct because it's created by an HTMLEDITOR.

Upvotes: 0

Views: 3251

Answers (2)

m.edmondson
m.edmondson

Reputation: 30872

Try response.Write(Contents)

And take a look at HtmlDecode

Are you saying that ;&gt ;&lt etc is displaying on the browser, or only when you view the source?

Upvotes: 1

Luis
Luis

Reputation: 6001

use

literal1.Text  = this.HtmlDecode(contents);

Upvotes: 1

Related Questions