I\'m using Razor in MVC 3 and Asp.net C#.
I have a View with the following code. model.ContentBody
has some HTML tags.
I would need display this HTM
@Html.Raw
was not work for me here is example:-
string name = "<p><span style="font-size: small; color: #ff0000;"><span style="font-size: small;"> <span style="font-size: large; color: #000000;">Hi</span><br /> <br />This is just a sample,<br />This will not work with @Html.Raw(),<br />";
@Html.Raw(name);
But this worked instead:-
@MvcHtmlString.Create(HttpUtility.HtmlDecode(@model.ContentBody))
or you can also use :-
@Html.Raw(HttpUtility.HtmlDecode(@model.ContentBody));