Skip to content

ASP.NET MVC Validation Refresh: Best Techniques & Frameworks

I just wanted to do a “refresher” post regarding ASP.NET MVC validation as many things have changed over the last couple of months and there is a lot of information out there.  I wanted to aggregate my known validation options and recommend them in one tabular list.  Whilst I’m scared to write “best practice” now a days, I do believe that the below list is really worthwhile, and are the most prominent and reputable on the net, and one in particular, the xVal framework I am using in a real-world project with absolutely no hassles and no apparant drawbacks.  However, I write that disclaimer as there is always something else out there :) . So without further ado, Ill get to the list, which is hopefully simple and easy to follow.

I hope this list can help alleviate any confusion amongst anyone not sure on the best path to go down, or at least provide a good starting point for those of you new to ASP.NET MVC and a validation strategy.

Technique/tool Author Release date Server-side support
(validation performed by .NET out-of-the-box)
Client-side support
(validation performed by JavaScript out-of-the-box)
Client “ajax” server-side support
(validation performed by JavaScript AJAX call to server-side .NET validation out-of-the-box)
ORM-targeted Rating
xVal Framework (tutorial here / L2S? See below.) Steve Sanderson Jan 10 2009 check* check delete check star_yellowstar_yellowstar_yellowstar_yellowstar_yellow
devermind.com: Client-side form validation made easy (w/ xVal) Adrian Grigore Jun 21 2009 check check check check star_yellowstar_yellowstar_yellowstar_yellowstar_yellow
Validator Toolkit for ASP.NET MVC (haven’t tried it!) Jürgen Bäurle Jan 29 2008 check check ? ? ???
Error Handling with built-in ModelState object Microsoft Framework release check delete delete delete star_yellowstar_yellowstar_yellow
Error handling with built-in IDataErrorInfo Interface Microsoft Framework release check delete delete delete star_yellowstar_yellowstar_yellow
Error handling with built-in Data Annotation Model Binding Interface Microsoft Framework release check delete delete check star_yellowstar_yellowstar_yellow

WHAT I RECOMMEND:
xVal + if you need client-side “ajax” validation calls, Adrian Grigores’ RemotePropertyValidator API which snaps right on to xVal.

* IF YOU CHOOSE XVAL (GREAT!):
Are you using LINQ to SQL and wish to declare your validation rules via .NET Data Annotations attributes? If so, click here.
(This outlines how to get this working so L2S re-generation doesn’t interfere with your property attributes for your model.)

If anyone has seen my older validation articles you’ll notice I had an Emad Ibrahim “validation hybrid”, but since xVal came along this is my framework of choice and also Emad’s didn’t support Linq to Sql.

If you have any others, comment and I’ll post them for others.

VN:F [1.9.1_1087]
Rating: 4.6/5 (12 votes cast)
VN:F [1.9.1_1087]
Rating: 0 (from 2 votes)
ASP.NET MVC Validation Refresh: Best Techniques & Frameworks, 4.6 out of 5 based on 12 ratings
Bookmark and Share
kick it on DotNetKicks.com
Shout it

NOW, FOR A WORD FROM OUR SPONSORS

4 Comments

  1. Super helpful! Thanks. :)

    VA:F [1.9.1_1087]
    Rating: 5.0/5 (1 vote cast)
    VA:F [1.9.1_1087]
    Rating: 0 (from 0 votes)
    Posted on 25-Jun-09 at 9:42 am | Permalink
  2. Alex

    very good article
    thank you very much

    VA:F [1.9.1_1087]
    Rating: 5.0/5 (1 vote cast)
    VA:F [1.9.1_1087]
    Rating: 0 (from 0 votes)
    Posted on 06-Aug-09 at 12:51 pm | Permalink
  3. Guramrit Singh

    Check this out.
    http://aspnetmvcval.codeplex.com/

    VA:F [1.9.1_1087]
    Rating: 5.0/5 (2 votes cast)
    VA:F [1.9.1_1087]
    Rating: 0 (from 0 votes)
    Posted on 04-Nov-09 at 1:26 am | Permalink
  4. Great guide, thanks a heap man.

    VA:F [1.9.1_1087]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.1_1087]
    Rating: 0 (from 0 votes)
    Posted on 25-Nov-09 at 2:44 am | Permalink

One Trackback/Pingback

  1. ASP .Net MVC – Validation « packtHub on 15-Feb-10 at 4:26 am

    [...] techniques here Possibly related posts: (automatically [...]

Post a Comment

Your email is never published nor shared. Required fields are marked *
*
*
My name is Graham O'Neale and I'm a software architect from Gold Coast, Australia. I am an overtime thinker, full time coder and awake part time in the real world. I have a keen interest in software development, particularly in the realm of programming (C#, ASP.NET, ASP.NET MVC, LINQ (2 SQL), Entity Framework, Silverlight, Blend, WCF, WPF) and a keen interest in the cutting edge and innovation. I have a new found love for design patterns, ALT.NET practices and well crafted software architecture. The purpose of this blog is to express any thoughts, findings, tips and gripes along my travels in the wonderful world of coding and technology...