Data validation is a key aspect for developing web application. In Asp.net MVC, we can easily apply validation to web application by using Data Annotation attribute classes to model class. Data Annotation attribute classes are present in System.ComponentModel.DataAnnotations namespace and are available to Asp.net projects like Asp.net web application & website, Asp.net MVC, Web forms and also to Entity framework ORM models.
Data Annotations help us to define the rules to the model classes or properties for data validation and displaying suitable messages to end users.
Data Annotation Validator Attributes:-
1. DataType :-
Specify the datatype of a property
2. DisplayName : -
specify the display name for a property.
3. DisplayFormat : -
specify the display format for a property like different format for Date property.
4. Required :-
Specify a property as required.
5. ReqularExpression :-
validate the value of a property by specified regular expression pattern.
6. Range :-
validate the value of a property within a specified range of values.
7.StringLength :-
specify min and max length for a string property.
8. MaxLength :-
specify max length for a string property.
9. Bind :-
specify fields to include or exclude when adding parameter or form values to model properties.
10. ScaffoldColumn :-
specify fields for hiding from editor forms.
Data Annotations help us to define the rules to the model classes or properties for data validation and displaying suitable messages to end users.
Data Annotation Validator Attributes:-
1. DataType :-
Specify the datatype of a property
2. DisplayName : -
specify the display name for a property.
3. DisplayFormat : -
specify the display format for a property like different format for Date property.
4. Required :-
Specify a property as required.
5. ReqularExpression :-
validate the value of a property by specified regular expression pattern.
6. Range :-
validate the value of a property within a specified range of values.
7.StringLength :-
specify min and max length for a string property.
8. MaxLength :-
specify max length for a string property.
9. Bind :-
specify fields to include or exclude when adding parameter or form values to model properties.
10. ScaffoldColumn :-
specify fields for hiding from editor forms.
No comments:
Post a Comment