Updated validation in Web Pages v2
Posted by: mikes web log,
on 08 Feb 2012 |
View original | Bookmarked: 0 time(s)
In v1 of ASP.NET Web Pages, you could add user-input validation by doing something like this in code:if (name.IsEmpty()) { ModelState.AddError("Name", "You must enter a name.");}In v2, there's a new Validation helper that has some nifty features:Methods to check for required fields, data types, string length, numeric ranges, the same values in two fields (as for new passwords), and patterns (i.e., RegEx).Methods to display both field-specific and summary validation error messages.Both...