Validating Data Using Data Annotation Attributes in ASP.NET MVC
- by bipinjoshi
The
data entered by the end user in various form fields must be validated
before it is saved in the database. Developers often use validation HTML
helpers provided by ASP.NET MVC to perform the input validations.
Additionally, you can also use data annotation attributes from the
System.ComponentModel.DataAnnotations namespace to perform validations
at the model level. Data annotation attributes are attached to the
properties of the model class and enforce some validation criteria. They
are capable of performing validation on the server side as well as on
the client side. This article discusses the basics of using these
attributes in an ASP.NET MVC application.http://www.bipinjoshi.net/articles/0a53f05f-b58c-47b1-a544-f032f5cfca58.aspx