?
Solved

Textbox maxlength

Posted on 2004-11-18
7
Medium Priority
?
2,817 Views
Last Modified: 2012-08-14
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.

0
Comment
Question by:miyengar
  • 2
  • 2
5 Comments
 
LVL 9

Expert Comment

by:Rodney Helsens
ID: 12618225
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
http://www.extremeexperts.com/Net/tools/MultiLineTextBox.aspx
0
 
LVL 9

Expert Comment

by:Rodney Helsens
ID: 12618238
0
 

Author Comment

by:miyengar
ID: 12619375
I want to use custom validator to check the length.  Can someone help me with the code
0
 
LVL 12

Accepted Solution

by:
sachitjain earned 200 total points
ID: 12625512
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; }
                }      
</script>
0
 

Author Comment

by:miyengar
ID: 12645280
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.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question