Sunday, 12 January 2014

MVC 4: How do I line-wrap my text in an editor?

The solution is to add an annotation to the field in the model class:

[DataType(DataType.MultilineText)]

Then, to display the item in the view, use Html.Raw.

@Html.Raw("<pre>"+ Html.Encode(@Model.MyField) + "</pre>"

No comments:

Post a Comment