Search code examples
htmlmodel-view-controllertinymce-4fckeditor

MVC shows the htmlcode inside my webpage that is created by tiny mce


I am using tiny mce (a kind of editor like fckeditor ) .so i use that to get my news content .

when i save the content of tiny mce textbox something like this is saved to the database :

<p>this is a test </p>
<p>good luck</p> 

I use the @html.raw(newstext) .But the browser shows this :

enter image description here

best regards.


Solution

  • The content is stored in your database as encoded HTML so to display it you need to decode. So this should work:

    @Html.Raw(HttpUtility.HtmlDecode(newstext))
    

    Or you can most likely drop the Raw method too and just go with:

    @HttpUtility.HtmlDecode(newstext)