开发者

Show HTML field from the database in ASP.NET MVC3 view

开发者 https://www.devze.com 2023-04-12 13:01 出处:网络
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:

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)
0

精彩评论

暂无评论...
验证码 换一张
取 消