As we can use System.ComponentModel.DataAnnotations.DisplayAttributeto set labels for a property, I want to use it for a class, but it is not allowed for classes.
using System.ComponentModel.DataAnnotations;
[Display(Name = "A person")]
public class Person
{
[Display(Name = "A name")]
public string Name { get; set; }
}
Does anyone know a workaround for this?
EDIT: I want to use it on a strongly typed view. When I create a new strongly typed view, the class name is hardcoded in HTML, for example:
@model Models.Person
<fieldset>
<legend>Person</legend>
<div class="display-label">
@Html.LabelFor(model => model.Name)
</div>
</fieldset>
I want to do something similar to a property Name.
source
share