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 ?
Validation is more sensible at which Level Views Level or Model level in asp.net
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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.