@Html.DisplayFor(model => model.Description) This is the output this code gives, while the output should only be" /> @Html.DisplayFor(model => model.Description) This is the output this code gives, while the output should only be" /> @Html.DisplayFor(model => model.Description) This is the output this code gives, while the output should only be"/>

Html.DisplayFor shows tags as plain text

1.3k views Asked by At
<div id="contact-description">
    @Html.DisplayFor(model => model.Description)
</div>

Screenshot of output text

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

1

There are 1 answers

1
Liam On BEST ANSWER

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()