Solved

HTML from database changed into text

Posted on 2011-03-15
3
634 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

Turn Insights into Action

Communication across every corner of your business is essential to increase the velocity of your application delivery and support pipeline. Automate, standardize, and contextualize your communication processes with xMatters.

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!
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

690 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