Is there an elegant way to output the text in a model property's DisplayName attribute using LabelFor without encoding? The DisplayName attribute contains an em tag that need to rendered as raw HTML.

I'd like to avoid creating a custom helper unless it is unavoidable. If it's unavoidable please describe how to create a helper that can override LabelFor.

Property in the model:

[DisplayName("Title <em>&lt;title&gt;</em>")]
public string Title { get; set; }

Razor view:

@Html.LabelFor(model => model.Title, new {@class = "control-label col-md-2"}


enter image description here

Related posts

Recent Viewed