Reputation: 6562
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><title></em>")]
public string Title { get; set; }
Razor view:
@Html.LabelFor(model => model.Title, new {@class = "control-label col-md-2"}
Output:
Upvotes: 3
Views: 776
Reputation: 2985
Sorry, but it seems there is no way of doing this like this post with original helper source code is showing:
Adding html spans into a LabelFor - MVC 3
Seems like you have to implement your own helper.
Upvotes: 1