Solved

HTML from database changed into text

Posted on 2011-03-15
3
632 Views
Last Modified: 2012-06-21
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
0
Comment
Question by:fusioninternet
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 500 total points
ID: 35136701
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
 
LVL 2

Expert Comment

by:sylenix
ID: 35136982
check the character encoding used by your SQL it should be a charset that can be displayed by your browser.
0
 
LVL 1

Author Closing Comment

by:fusioninternet
ID: 35140354
That did the trick.

Thanks very much.
0

Featured Post

Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question