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

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

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

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:
    536
    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,309
    coollzh
    Apr 11, 2004
  3. hardcoded

    maxlength on multiline textbox

    hardcoded, May 5, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    19,471
    cnicol
    Sep 26, 2007
  4. Craig G
    Replies:
    2
    Views:
    1,040
    Karl Seguin
    Feb 15, 2005
  5. Nathan Sokalski
    Replies:
    3
    Views:
    65,499
    zed_rhodes
    May 29, 2009
  6. Not Me
    Replies:
    5
    Views:
    588
    Not Me
    Oct 6, 2006
  7. kalaiselvan
    Replies:
    1
    Views:
    283
    Ken Cox [Microsoft MVP]
    Aug 8, 2003
  8. Nathan Sokalski

    TextBox's MaxLength does not work when TextMode=MultiLine

    Nathan Sokalski, Sep 4, 2005, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    303
    S. Justin Gengo
    Sep 4, 2005
Loading...