3

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.

1
  • Does @Html.Raw(result) work? Commented Feb 14, 2012 at 15:07

1 Answer 1

7

You could use: @Html.Raw(result)

Or use an MvcHtmlString instead of the normal string.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.