Method 1: Verify the control (Practical and feasible)
Setting the maxength of a textbox when it is in multiline, you can use regularexpressionvalidator control as shown below
<Asp: textbox id ="Txtconclusion"Maxlength =" 200 "textmode =" multiline "Height =" 100px "width =" 400px "runat =" server "/>
<Asp: regularexpressionvalidator
Id = "txtconclusionvalidator1" controltovalidate ="Txtconclusion"
TEXT = "more than 200 words" validationexpression = "^ [\ s] {0,200} $"
Runat = "server"/>
Method 2: a dialog box is displayed.
1.html code
<HTML>
<Head>
<Title> webform6 </title>
<Meta name = "generator" content = "Microsoft Visual Studio. NET 7.1">
<Meta name = "code_language" content = "C #">
<Meta name = "vs_defaultclientscript" content = "JavaScript">
<Meta name = "vs_targetschema" content = "http://schemas.microsoft.com/intellisense/ie5">
<Script language = "JavaScript">
Function isover (stext, Len)
{
VaR intlen = stext. value. length;
If (intlen> Len)
{
Alert ("the content length must less than or equal" + Len );
Stext. Focus ();
Stext. Select ();
}
}
</SCRIPT>
</Head>
<Body ms_positioning = "gridlayout">
<Form ID = "form1" method = "Post" runat = "server">
<Asp: textbox id = "txtname" style = "Z-INDEX: 102; left: 200px; position: absolute; top: Running PX" runat = "server"
Textmode = "multiline" Height = "pixel PX" width = "271px"> </ASP: textbox>
</Form>
</Body>
</Html>
2. CS code private void page_load (Object sender, system. eventargs E)
{
This.txt name. Attributes. Add ("onblur", "isover (this, 1000 );");
}
Method 3: Custom Controls
Multiline textbox with maxlength Validation
Http://www.codeproject.com/KB/aspnet/Textarea_Length_Validator.aspx