?
Solved

HTML from database changed into text

Posted on 2011-03-15
3
Medium Priority
?
639 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 2000 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

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

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

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

752 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