mvc3 - How to disable htmlencode of symbols from source

我们两清 提交于 2019-12-08 14:54:16

问题


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.


回答1:


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




回答2:


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/



来源:https://stackoverflow.com/questions/4978549/mvc3-how-to-disable-htmlencode-of-symbols-from-source

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!