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


    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

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 (here). After that, you can post your question and our members will help you out.