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>
尝试使用Html.Raw
输出HTML:
<div>@Html.Raw(Model.HomePageText)</div>
您需要使用Html.Raw(Model.HomePageText)
,假设您确定不会有任何问题(脚本注入,有害的html等)。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.