HTML from database changed into text

Hi Experts,

I having trouble displaying some HTML on a page which is being read from an SQL database.

I've followed the introduction to MVC 3 here http://www.asp.net/mvc/tutorials/getting-started-with-mvc3-part1-cs which uses EFCodeFirst for the data connection. All is fine and now I'm using TinyMCE to format the text being saved. Which is also wokring fine as when I look into teh database the text is formatted in HTML.

My problem occurs when I display the desired field on another page. Instead of the text displaying formatted HTML, i get the text  HTML code dispalyed instead.

eg. <strong>Hello World</strong> is displayed as <strong>Hello World</strong> instead of bold "Hello World"

When looking at the source code it read back as:-
&lt;strong&gt;Hello World&lt;/strong&gt;

I'm displaying the field as simple as possible using just <%: Model.main_text %>

Any help on how to get this to display is greatly appreciated.

Steve
LVL 1
fusioninternetAsked:
Who is Participating?
 
Carl TawnSystems and Integration DeveloperCommented:
You'll need to use the Html.Raw() helper in order to make it interpret it as actual markup:
<%: Html.Raw(Model.main_text) %>

Open in new window

0
 
sylenixCommented:
check the character encoding used by your SQL it should be a charset that can be displayed by your browser.
0
 
fusioninternetAuthor Commented:
That did the trick.

Thanks very much.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.