Maxlength for mulitiple line text box

Is there any way to set maxlength for multipleline text box? <asp:textbox textmode=multiline....
Thanks for help.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You have to write client side code to check the length, or use a custom validator
CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

You can add following code in your Page_Load event for multiline textbox:

  TextBox1.Attributes.Add("onkeypress","if(this.value.length>=" + TextBox1.MaxLength + ") return false;");

tusharashah has a good point there. That will stop the input all together if it is exceeding the max length. The only problem with that is because the MaxLength attribute of the textarea field is an invalid attribute, you might not get a value back from TextBox1.MaxLength which means you would have to hard code the length.
TextArea is different then MultiLine TextBox
Not sure about the TextArea, but MaxLength is allowed in Multiline textbox.. so there's no worry over there..

A multiline textbox is rendered as a textarea. The textarea does not support the maxlength attribute. The only difference you see in programming it is that the multiline textbox is a server control while the textarea is an html control.

I'm not saying that it is not possible. I'm just saying becuase of my experience with text area fields, it is something to take note of, and I'm offering a work around in case that does end up being a problem.
CochiseCountyAuthor Commented:
Hi everyone,
here is what I did and it works (from

Code behind
Sub LengthCheck(ByVal sender As Object, ByVal args As ServerValidateEventArgs)
        If Len(txtComments.Text) > 250 Then
            args.IsValid = False
            args.IsValid = True
        End If
    End Sub
aspx page
<asp:CustomValidator runat="server" id="cvComments"
ErrorMessage="Exceed 250 characteres" Font-Bold=True />
That is pretty much the same thing I just posted for MikeMCSD's issue. Hopefully that works for him as well.
Closed, 125 points refunded.
The Experts Exchange
Community Support Moderator of all Ages

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.