Maxlength for mulitiple line text box

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

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

x
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.

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

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

tusharashahCommented:
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;");

fizchCommented:
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.
tusharashahCommented:
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..

-tushar
fizchCommented:
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 http://aspnet.4guysfromrolla.com/articles/073102-1.aspx)

Code behind
Sub LengthCheck(ByVal sender As Object, ByVal args As ServerValidateEventArgs)
        If Len(txtComments.Text) > 250 Then
            args.IsValid = False
        Else
            args.IsValid = True
        End If
    End Sub
aspx page
<asp:CustomValidator runat="server" id="cvComments"
ControlToValidate="txtComments"
OnServerValidate="LengthCheck"
ErrorMessage="Exceed 250 characteres" Font-Bold=True />
fizchCommented:
That is pretty much the same thing I just posted for MikeMCSD's issue. Hopefully that works for him as well.

http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/ASP_DOT_NET/Q_21797284.html
GranModCommented:
Closed, 125 points refunded.
GranMod
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
ASP.NET

From novice to tech pro — start learning today.