7

I am using a CKEditor on my MVC project. I'm saving HTML into the DB. WHen I read it and display it on screen, what I get is

   <p> <a href="http://www.cnh.com">www.cnh.com</a></p> <p>  </p>

I use Html.DisplayFor.

<td>
    @Html.DisplayFor(modelItem => item.SampleCollectionInstructions)
</td>

How can I make it display the links properly and one per line??

3 Answers 3

14

Use Raw method to return markup without html encoded Ex;

@Html.Raw("<div>Some text</div>")
Sign up to request clarification or add additional context in comments.

1 Comment

I used @Html.Raw(item.SampleCollectionInstructions) and it worked. Tks
6

If anyone else is confused about doing this in loops, like I was:

You can just omit both DisplayFor and modelItem =>, so:

@Html.Raw(item.SampleCollectionInstructions)

Comments

0

You can Use

@Html.Raw(WebUtility.HtmlDecode(Item.APPTXT)) 

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.