tags:

views:

147

answers:

2

Ok I've spent a lot of time reading all the various blog posts on Validation. We are currently in the middle of writing an app in MVC 2.0 and noticed the Model Validation Providers, can anyone provide any examples or links to good solid examples?

Cheers

A: 

XVal is the forerunner in this field, Steve Sanderson is a real smartie pants!

Kindness,

Dan

Daniel Elliott
This seems to be the way to do it MVC 1.0 I'm looking for the new way to do it in MVC 2.0
Pino
+3  A: 

This is an excellent example of the new jQuery validation provider (which is currently the default) in MVC 2 Preview 2 - http://blogs.msdn.com/rickandy/archive/2009/10/03/client-side-validation-for-mvc-2-p2.aspx

Kieron
For more examples of DataAnnatations validation provider, see ScottGu's blog: http://weblogs.asp.net/scottgu/archive/2009/07/31/asp-net-mvc-v2-preview-1-released.aspx
NickLarsen
Is this a Model Validation Provider?
Pino
Yes, the baked in jQuery validator is based on the Model Validation Provider. You can create your own, or get others and simply plug them in.
Kieron
ok cool, how would you go about server validation as well? Javascript validation is kinda out of the question because of the nature of the app.
Pino
The MVC 2 preview 2 validation does *both* client and server validation. The server validation is done during model binding.
Craig Stuntz
As Craig said, it handles both. The client-side validation is just sugar, the ModelState is still used server side.
Kieron