Is there a way in ASP.NET Webforms to accommodate开发者_StackOverflow中文版 attribute based validation. If so any urls where this has been demonstrated. I am not looking for open source projects. Just as you can use MVC Routing in Web Forms, can the validation framework be used?
Routing is common for whole asp.net, therefore - you can easily use it in webforms too.
'Attribute based validation' is based on so called DataAnnotations. They aren't even asp.net specific, but common for whole .net. Mvc framework just uses them etc.
You might find this tutorial useful. I'm not sure i would use such an approach - but it's certainly possible.
Check this out. A really good Validation Framework for ASP.Net Webforms.
http://imar.spaanjaars.com/QuickDocId.aspx?quickdoc=477
(source: spaanjaars.com)
Also check out the Microsoft Enterprise Library Validation Application Block. Compared to DataAnnotations, it has a much larger feature set, visual studio integration, more possibilities to be extended and future versions will be able to read DataAnnotations attributes, but it also has a much steeper learning curve. Because of its complexity it isn't always a good fit for small projects.
精彩评论