简体   繁体   中英

Html.DisplayFor shows tags as plain text

<div id="contact-description">
    @Html.DisplayFor(model => model.Description)
</div>

屏幕截图

This is the output this code gives, while the output should only be "Test". How to hide the Span tag?

Presuming your Description property value contains HTML tags (the <span> ):

You want @Html.Raw(Model.Description) . @Html.DisplayFor will automatically delimit HTML to prevent HTML injection. If your expecting HMTL output use Raw()

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM