Limiting the length of an ASP.net mulitline textbox control is easy. Add a RegularExpressionValidator, set the ControlToValidateProperty to the ID of the TextBox you wish to validate and set the ValidationExpression property to :

^[\s\S]{0,300}$

This tells the regex validator to limit the number of characters in the Textbox to 300.

Metacharacters

^ Start of Line
[] Character class (list the characters you want to match)
\s White space characters including new line
\S Non-white space characters
{intMin,intMax} Intervals; The minimium number of matches you want to require and the max number of matches you want to allow

Posted via email from fenildesai's posterous