TextBox - MaxLength property

Discussion in 'ASP .Net Web Controls' started by mg, Apr 11, 2004.

  1. mg

    mg Guest

    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?
     
    mg, Apr 11, 2004
    #1
    1. Advertising

  2. mg

    Teemu Keiski Guest

    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


    "mg" <> wrote in message
    news:...
    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?
     
    Teemu Keiski, Apr 11, 2004
    #2
    1. Advertising

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

    http://www.4GuysFromRolla.com
    http://www.ASPFAQs.com
    http://www.ASPMessageboard.com

    * When you think ASP, think 4GuysFromRolla.com!
     
    Scott Mitchell [MVP], Apr 16, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Darren Clark
    Replies:
    1
    Views:
    450
    Andrew de la Harpe
    Apr 10, 2004
  2. =?Utf-8?B?bWc=?=

    TextBox - MaxLength property

    =?Utf-8?B?bWc=?=, Apr 11, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    4,099
    coollzh
    Apr 11, 2004
  3. hardcoded

    maxlength on multiline textbox

    hardcoded, May 5, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    19,093
    cnicol
    Sep 26, 2007
  4. Craig G
    Replies:
    2
    Views:
    954
    Karl Seguin
    Feb 15, 2005
  5. kalaiselvan
    Replies:
    1
    Views:
    202
    Ken Cox [Microsoft MVP]
    Aug 8, 2003
Loading...

Share This Page