Textbox maxlength

I want to set the maxlength property of a textbox with the textmode as multiline.  How can i use the maxlength property to set my textbox in such a way it does not let the user to enter more than the maxlength property. Again it is a multiline textbox.

Who is Participating?
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.

Rodney HelsensCommented:
Restricting length of the text in Multiline textbox is not supported in ASP.NET Web control, you can accomplish the maxlength property by using a RegularExpression Validator... check the link below.

taken from
Rodney HelsensCommented:
miyengarAuthor Commented:
I want to use custom validator to check the length.  Can someone help me with the code
You can use custom validator like this

<asp:customvalidator id="CustomValidator1" runat="server" CssClass="instructionSmall" ControlToValidate="TextBox1" ErrorMessage="Maximum 5000 characters allowed." Display="Dynamic" ClientValidationFunction="ClientValidate"></asp:customvalidator>

<script language="javascript">
            function ClientValidate(source,args) {
                  if(args.Value.length >= 5000)
                            args.IsValid = false;
                  else { args.IsValid = true; }

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
miyengarAuthor Commented:
The above code works fine but had a question on that:
5000  the max length is being hardcoded.  Instead of hard coding, in another textbox I want to enter maxlength which may vary each time and then use that value in my program rather than hardcoding 5000 as max length. Any solution on that. I appreciate ur help.
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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.