TextBox - MaxLength property

M

mg

I have a MultiLine TextBox (WebForm - C#) with the MaxLength property = 1000 but am able to type in an unlimited number of characters. Is there a way to limit the number of characters that can be typed into this TextBox?
 
T

Teemu Keiski

MaxLength property works only with single-line TextBox (its not about
ASP.NET but HTML and how TEXTAREA vs INPUT behaves). You'd need to write
custom validation to check the length when typing.

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
http://blogs.aspadvice.com/joteke


I have a MultiLine TextBox (WebForm - C#) with the MaxLength property = 1000
but am able to type in an unlimited number of characters. Is there a way to
limit the number of characters that can be typed into this TextBox?
 
S

Scott Mitchell [MVP]

I have a MultiLine TextBox (WebForm - C#) with the MaxLength property = 1000 but am able to type in an unlimited number of characters. Is there a way to limit the number of characters that can be typed into this TextBox?

As Teemu pointed out, this is a limitation of the multi-line TextBox,
and you need to use a custom validator and (ideally) client-side
JavaScript to limit this. See
http://forums.aspfree.com/showthread.php?t=18846 for a discussion of how
to write some client-side JavaScript to not permit the user to enter
more than a specified number of characters...

Hope this helps...

--

Scott Mitchell
(e-mail address removed)
http://www.4GuysFromRolla.com
http://www.ASPFAQs.com
http://www.ASPMessageboard.com

* When you think ASP, think 4GuysFromRolla.com!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top