4

I have a SQL table that contains HTML formatting for text shown.

<strong>What Is EDI ?</strong><p>EDI is a method for communicating electronically with trading partners based upon standards.</p>

Within my MVC application there is an index.cshtml page below:

<h2>Index</h2>
<table>
    <tr>
        <th> @Html.DisplayNameFor(model => model.Body)</th>
        <th></th>
    </tr>
@foreach (var item in Model) {
    <tr>
        <td>@Html.DisplayFor(modelItem => item.Body)</td>
    </tr>
}
</table>

The problem is that the text is appearing as normal with no HTML formatting. Can anybody help to fix the issue I am having?

0

1 Answer 1

6

You have to use @Html.Raw() for this purpose.

Instead of

@Html.DisplayFor(modelItem => item.Body)

Use

@Html.Raw(item.Body)

Reference.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.