I’ve got a class with a property that looks like this:
[AllowHtml]
[DataType(DataType.MultilineText)]
public string Description { get; set; }
I’ve already put in the [AllowHtml]
attribute to let me submit HTML to this property via the form that I’ve built, but what I want to do is output the value of the property as the raw HTML without it being escaped.
I know I can use Html.Raw(Model.Description)
but what I’m looking for is some way of telling Html.DisplayFor(m => m.Description)
to always output the raw HTML. Is there an attribute I can use to decorate the properties in my class that I wish to behave like that?
Basically it’s me being lazy—I don’t want to have to remember which properties might contain HTML, so I don’t want to have to think about using Html.Raw(…)
when I need to do the above—I’d much rather my Model know what it should do and do it automatically. I’ve tried searching for an answer, but either I’m not phrasing it correctly or there’s no way of doing it :(
Thanks,