Superfrallan
Superfrallan

Reputation: 43

My text isn't html?

I am using ckeditor to save my texts... (asp.net mvc)

In the database the text are stored like this:

<ul><li>List item</li><li>List item</li><li>List item</li></ul>

And when I am running my website I want it look like this:

But the text are the same as in the database:

<ul><li>List item</li><li>List item</li><li>List item</li></ul>

And the source code are:

  &lt;ul&gt;
    &lt;li&gt;
        List item&lt;/li&gt;
    &lt;li&gt;
        List item&lt;/li&gt;
    &lt;li&gt;
        List item&lt;/li&gt;
&lt;/ul&gt;

What am I missing?

Upvotes: 3

Views: 83

Answers (2)

TimS
TimS

Reputation: 6042

Try using Server.HtmlDecode:

http://msdn.microsoft.com/en-us/library/hwzhtkke.aspx

Upvotes: 0

Nick Craver
Nick Craver

Reputation: 630379

Your text is being HTML encoded, if for example you're using <%: Prop %> this will happen, if you want it to render exactly, you want <%= Prop %>. There are a dozens of ways to get HTML into a page so I'm not sure exactly which method you're taking, but whichever way it is, it's passing through the Html encoder along the way.

Keep in mind storing the text and displaying it like this does render your site vulnerable to cross-site scripting and other attacks, so you will probably want to sanitize the incoming HTML.

Upvotes: 5

Related Questions