To spare the rest of you the headache; MVC 3 does not support the MaxLength attribute any longer.
In stead you can now use the StringLength attribute which also replaces the MinLength attribute through a named parameter.
Some examples:
Seems you still need to use MaxLength attribute for Entity Framework though.
In stead you can now use the StringLength attribute which also replaces the MinLength attribute through a named parameter.
Some examples:
- Set the maximum string length to 50:
1: [StringLength(50, ErrorMessage = "{0} has a maximum of {1} characters")]
- Set the maximum and minimum string length:
1: [StringLength(50, MinimumLength=10, ErrorMessage = "{0} has a maximum of {1} and a minimum of {2} characters")]
Seems you still need to use MaxLength attribute for Entity Framework though.
Great post! You make my day!
BeantwoordenVerwijderen