views:

63

answers:

1

Validation is more sensible at which Level Views Level or Model level in asp.net MVC & also link of good Tutorial on Validation in MVC ?

+3  A: 

Validation should ALWAYS be done at the client where possible AND the server (the Model in the case of MVC.)

ScottGu has a good blog article about validation in MVC2. Be aware that many folks have been having problems with the "automatic" DataAnnotations-based client-side validation. You're supposed to be able to add attributes like [Required] to properties of your Model or ViewModel, and the MVC system is supposed to automatically emit client-side validators for the fields for those properties. In practice I haven't been able to make that work.

Manually adding jQuery validators does work, however. If you use Ajax.BeginForm(), you can set the OnBegin parameter of the AjaxOptions to the name of your javascript validation function.

Dave Swersky
Thanks its very helpful.
SAHIL SINGLA