It is strange Asp.net Text box with multi line attribute does not support max lenth property. we need to manage it by writing customized java script Code.
views:
109answers:
2because the textbox-mode multiline is rendered as textarea, and the textarea does not contain a maxlength property.
yes, apply a javascript, and, to be sure add also some server-side check for the length (if the client disables javascript)
TextBox, when multi-line, renders a TextArea that does not contain a MaxLength property.
TextBox control should act different as for the output of the MaxLength property depending on the TextMode property. If it's single-line, render MaxLength, if it's not, render a JavaScript. I consider it a bad behavior or maybe a bug.
In these cases when you are curious you can always take a look at Microsoft's code with Reflector.
Here's the code snippet for MaxLength property rendering in the AddAttributesToRender
method:
int maxLength = this.MaxLength;
if (maxLength > 0)
{
writer.AddAttribute(HtmlTextWriterAttribute.Maxlength, maxLength.ToString(NumberFormatInfo.InvariantInfo));
}
maxLength = this.Columns;
if (maxLength > 0)
{
writer.AddAttribute(HtmlTextWriterAttribute.Size, maxLength.ToString(NumberFormatInfo.InvariantInfo));
}