I have a Model filed that returns an HTML string with line break BR tag, but How do I display that HTML on the browser ? The problem ins instead putting the line break, the
Try this :
@(new HtmlString(stringWithMarkup))
and you can create a HTML helper too!:
@helper RawText(string s) {
@(new HtmlString(s))
}
You can just omit both DisplayFor and modelItem =>, so:
@Html.Raw(item.Speaking)
In MVC4
Instead of using @Html.Raw(modelItem => item.Speaking)
You can use
@Html.Raw(@Model.Speaking.ToString())
It works for me and I hope this help someone else too
MVC 5
@Html.Raw(WebUtility.HtmlDecode(item.Speaking))