0

I have a field in db which stores html and i want to render that html on userside. but i am unable to do so. when i tried to put html in div tag or paragraph tag then i get simply html text. here is my code which i tried

<%: HttpContext.Current.Server.HtmlDecode(Model.HomePageText) %>

and i get following result by using this (HTML appears as text)

<p> </p> <p style="color: rgb(88, 100, 109); font-family: 'PT Sans', sans-serif; font-size: 13px; line-height: 16px; background-position: -1px -350px; "> Enter custom CSS code into the box below to further customize your mobile site.</p>

2 Answers 2

6

Try using Html.Raw to output your HTML:

<div>@Html.Raw(Model.HomePageText)</div>
Sign up to request clarification or add additional context in comments.

1 Comment

@AnkushJain Please consider Rewarding Marek by marking his answer as accepted if he helped solve your problem. :)
2

You need to use Html.Raw(Model.HomePageText), assuming you're certain there won't be any issues (script injection, harmful html etc).

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.