Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 17-01-2009
Member
 
Join Date: Dec 2008
Posts: 9
Set maxlength property on multiline textbox in Asp.net

Hi all,

In my Asp.net project,
I have a textbox with TextMode set to MultiLine. I also have the MaxLength property of textbox set to 100. This maxlength value seems to get ignored as the user can enter unlimited characters.

So how can i set the maxlength for Multiline textbox ?
Reply With Quote
  #2  
Old 17-01-2009
Member
 
Join Date: May 2008
Posts: 2,383
Re: Set maxlength property on multiline textbox in Asp.net

When the TextMode property of textbox is set to Multiline, the MaxLength property wont be handled in controlling the maximum length of users inputs.

The users can enter as much charaters as he wants in Multiline Textbox even MaxLength of this textbox is set to a particular value.
Obviously, this is a bug of ASP.NET.

For the solution to this problem you have to create your own function according to your logic to set the maxlength property of text box.
Reply With Quote
  #3  
Old 17-01-2009
Member
 
Join Date: Feb 2008
Posts: 1,848
Re: Set maxlength property on multiline textbox in Asp.net

You can use this function.

Code:
function CheckLength(text,long) 

{
	var maxlength = new Number(long); // Change number to your max length.
	if (text.value.length > maxlength)
       {
		text.value = text.value.substring(0,maxlength);

		alert(" Only " + long + " chars");

	}
}

and use this function in the text box events as given below,

onKeyUp="CheckLength(this,200)"
onChange="CheckLength(this,200)"
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Set maxlength property on multiline textbox in Asp.net"
Thread Thread Starter Forum Replies Last Post
Multiline screen fault in Sony Bravia KDL-32D3000 TV ElroyDJ Monitor & Video Cards 9 14-01-2012 02:21 AM
Excel/VBA: Copying text from UserForm Textbox to a Worksheet Textbox Neil Ives Software Development 2 20-08-2010 01:23 AM
vb.net multiline string CAITLIN Software Development 3 13-07-2009 12:51 PM
How to set the maxlength of the textboxes dynamically Sophia Software Development 3 18-03-2009 12:00 AM
How to lock a textbox need property through code. rupak Software Development 2 27-02-2009 10:50 PM


All times are GMT +5.5. The time now is 03:03 AM.