How to validate using Data annotation(MVC tutorial number 11)? - Online Free Computer Tutorials.

'Software Development, Games Development, Mobile Development, iOS Development, Android Development, Window Phone Development. Dot Net, Window Services,WCF Services, Web Services, MVC, MySQL, SQL Server and Oracle Tutorials, Articles and their Resources

Friday, April 20, 2012

How to validate using Data annotation(MVC tutorial number 11)?

Validating data is one of the key things in any web application. As a developer you would like to run validation both on the client side (browser) and also on the server side.

So you would probably like to write the validation once and then expect the validation framework to generate the validation logic on both the ends.

Good news, this is possible by using data annotations.

In MVC you validate model values. So once the data comes inside the model you would like to question the model saying, is the data provided proper?, are values in range ? etc.

Data annotations are nothing but the metadata which you can apply on the model and the MVC framework will validate using the metadata provided.

No comments:

Post a Comment