How to display HTML stored in a database from an ASP.NET MVC view?

I have HTML code emitted by FCKEditor stored in a database and would like to display (well render) it onto a view. So, for instance, something stored as:

<>pre<>This is some sample text<>pre</&gt

Will be displayed to the user as:

This is some sample text

(With the appropriate style for pre-formatted-text)

The view already has the required string to display from ViewData, I'm just not sure what the best way to show it to the user is.

Answers


try

<%= System.Web.HttpUtility.HtmlDecode(yourEncodedHtmlFromYouDatabase) %>

more info here @ MSDN online.

hth!


Need Your Help

find works, but find -exec doesn’t

osx shell find args

I am trying to find all images in subfolders of a given folder, and move them somewhere else. I have tried the following in zsh (my default) and sh (what most tutorials seem to be using) on a Mac r...

scriptaculous: onmouseover /onmouseout for several ids and flickering problem

javascript function scriptaculous onmouseover onmouseout

Hi so basically what I want to do is to have the same event happen to different images and only write the code line one time in a .js file. This should be very basic but I can't find any easy guide.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.