Is there an annotation to set the Label-name of the property?
Ex:
public class MyModel
{
[LabelName("Your Phone")]
public string Phone{get;set;}
}
Thanks
And then in the view, it would show the name "Your Phone"
<%=Html.LabelFor(Model.Phone)%>
In ASP.NET MVC, Data Annotation is used for data validation for developing web-based applications. We can quickly apply validation with the help of data annotation attribute classes over model classes.
Data annotations (available as part of the System. ComponentModel. DataAnnotations namespace) are attributes that can be applied to classes or class members to specify the relationship between classes, describe how the data is to be displayed in the UI, and specify validation rules.
Data annotation is the categorization and labeling of data for AI applications. Training data must be properly categorized and annotated for a specific use case. With high-quality, human-powered data annotation, companies can build and improve AI implementations.
Use [DisplayName("Your Phone")]
instead of [LabelName("Your Phone")]
If you mean the actual content of the label to be displayed on the page, yes. It is
[Display (Name= "Your Display content")]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With