Reputation: 155
I have some code like
@{
string result = "<div> text </div><br />";
}
and I want print content of this variable into some html
<div id="seachResult2">
Search results: @Server.HtmlDecode(result);
</div>
but it doesn't work. I know about HtmlString class and it has ToHtmlString and ToString methods but I can't find something like string.ToHtml().
It is my first question here. I hope somebody will help me to solve this problem.
Upvotes: 3
Views: 6456
Reputation: 936
You could use: @Html.Raw(result)
Or use an MvcHtmlString
instead of the normal string.
Upvotes: 7