views:

41

answers:

2
+3  Q: 

My text isnt 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:

  • List item
  • List item
  • List item

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?

+5  A: 

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.

Nick Craver
A: 

Try using Server.HtmlDecode:

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

TimS
He did not need Decode, just not encode it when its render.
Aristos