0

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 advance for any help! Be easy on me:)

2
  • How do you display it on the page? Commented Oct 11, 2011 at 18:49
  • Real curious as to why I got a downvote weeks after I accepted my answer. Love StackOverflow, but some of the people in the community are ODD. Commented Nov 4, 2011 at 15:26

2 Answers 2

2

Try

Decoded

@Html.Raw(HttpUtility.HtmlDecode(Model.YourHtmlContent));

Unenconded

@Html.Raw(Model.YourHtmlContent);
Sign up to request clarification or add additional context in comments.

Comments

1

if you're using razor views use

@Html.Raw(model.foo)

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.