Show HTML field from the database in ASP.NET MVC3 view
I feel like this should be easy, but it seems to be stumping me.
I have a database field that contains HTML. For instance, the field may contain the following:
<html>
<p>This is HTML from the database.</p>
</html>
Now, all I want to do is render this HTML onto the page. Instead it is displaying the actual HTML markup.
I am sure this is simple, but I have been searching around for a while and have yet to find a solution.
Thanks in adv开发者_如何学编程ance for any help! Be easy on me:)
Try
Decoded
@Html.Raw(HttpUtility.HtmlDecode(Model.YourHtmlContent));
Unenconded
@Html.Raw(Model.YourHtmlContent);
if you're using razor views use
@Html.Raw(model.foo)
精彩评论