mvc3 - How to disable htmlencode of symbols from source
Asked Answered
B

2

14

I need to out on my page text from database table. Table field "Text" Contains text with html formatting tags like <p>, <br/> etc... (in table its not encoded!)

When i'm trying to output with @Model.Text i see encoded html tags like &lt;p&gt; How can i disable this html-encode. Thank you.

Blacksnake answered 12/2, 2011 at 14:21 Comment(0)
N
26

You can use @Html.Raw(Model.Text) to achieve this.

Neal answered 12/2, 2011 at 14:24 Comment(2)
I love short answers to frustrating problems.Pinnatiped
nop not worked for me it's given <p> </p> contain? please helpTourniquet
S
5

If you are using the <%: syntax in your views, it will automatically encode all output. Using <%= does not perform the encoding.

More details can be found at http://jeffreypalermo.com/blog/what-is-the-difference-in-lt-variable-gt-and-lt-variable-gt-in-asp-net-mvc/

Sinless answered 12/2, 2011 at 14:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.