1.[required]: Must be entered
" Please enter user name ")]
2.[stringlength]: Limit string length
[Stringlength ( length cannot exceed 10 characters ")]
3.[range]: Limit the range of values
[Range (0" age range between 0-120 years old ")]
4.[regularexpression]: must conform to a regular expression (1) Use regularexpression directly to write expressions:
. [RegularExpression (@ "^\w+ ([-+.] \w+) *@\w+ ([-.] \w+) *\.\w+ ([-.] \w+) *$"" Please enter email format "). Public Get Set
(2) Custom features:
Public class Emailattribute:regularexpressionattribute { public emailattribute () :base(@ " ^\w+ ([-+.] \w+) *@\w+ ([-.] \w+) *\.\w+ ([-.] \w+) *$") { } }
Comparison of 5.Compare Judgments
Public class Emailattribute:regularexpressionattribute { public emailattribute () :base(@ "^\w+ ([-+.] \w+) *@\w+ ([-.] \w+) *\.\w+ ([-.] \w+) *$") { } }
6.remote:ajax Remote Authentication, the return value is bool type TRUE indicates validation passed
// The action method Controller class request method [Remote("User""Validate " " Post " " user name already exists " )] publicstring Get set; // .... Public actionresult User () { //.. if (true) { return Json (true, jsonrequestbehavior.allowget); } Else return Json (false, jsonrequestbehavior.allowget); }
7.OutputCache Page Caching
[OutputCache (duration=)] // Set page Absolute cache cache time is 20 seconds public actionresult Index () { // Detail Code }
Transferred from: http://www.cnblogs.com/iack/p/3500720.html