Explain Data Annotations.
Data Annotations
- Data Annotations (sometimes referred to as Model Attributes), which basically allow you to add metadata to a property.
- The cool thing about DataAnnotations is that they don't disturb the use of your Models outside of the MVC framework.
- When generating the label, the name of the property is used, but property names are generally not nice to look at for humans. As an example of that, we might want to change the display version of the FirstName property to "First Name".
public class WebUser
{
[Display (Name="First Name")] public string FirstName { get; set; }
}
Comments
Post a Comment