Selecting a Validation Framework - ASP.NET
Which validation framework would you prefer for a webforms application. This would be for a rather large complex app. I would want to specify rulesets and business validation in a single place and integrate it both on the client and server side. I'd prefer jquery for cl开发者_如何学Cient side.
Anyone has any suggestions?
You can look at .NET 3.5 DataAnnotations. because it integrates well with ASP.NET, but I don't believe it supports the concepts of rule sets. Another option is Enterprise Library Validation Application Block, which supports custom rule sets, however, it will take you slightly more time to integrate that with ASP.NET. However there is online material that should give you a kick start. Here an article (written by myself) about integrating VAB with O/RM tools and here is an interesting article about integrating VAB with ASP.NET.
Good luck.
For WebForms, the standard validators provide a good base, if you use jQuery, you can replicate the asp.net validation checks quite easily and react accordingly, ie replace and provide better feedback to the user than the Validation Summary control.
for instance you can find the validation controls using jquery, validate and get the control-to-validate to target, this will help in getting error messages, change form field classes etc.
For web forms or MVC? Here are the options I've seen so far:
- JQuery validate plugin (client side only)
- XVal: xval.codeplex.com, has client and server side components, but I think it's MVC only. Not sure. I do believe this integrates with teh JQuery validate plugin.
- Enterprise library validation app block - server-side only last time I checked, but great way to supply your logic. Can supply rules in config file, as attributes on your code, or alternative stores. You could then use JQUery validate for the front-end. Not a single solution for client/server.
- Standard ASP.NET validators, which does work client and server side. Both ASP.NET and MVC have implementations as you probably now.
精彩评论