Setting the maxlength property of a multiline textbox

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gomzi
    Contributor
    • Mar 2007
    • 304

    Setting the maxlength property of a multiline textbox

    hi,
    I am trying to set the maxlength property of a multiline textbox without much success. Could anyone tell me as to how it could be done ?

    thanks,
    gomzi.
  • SammyB
    Recognized Expert Contributor
    • Mar 2007
    • 807

    #2
    This works for me:
    Code:
    TextBox1.Multiline = True
    TextBox1.MaxLength = 10
    But, if I enter 1, 2, 3, 4 on four lines, one character per line, then I cannot enter any more characters because the newline is included in the character count.

    Or, did you mean that you wanted to set the maximum number of characters per line. You would have to do this manually in the TextChanged event with the split function.

    HTH --Sam

    Comment

    • gomzi
      Contributor
      • Mar 2007
      • 304

      #3
      Originally posted by SammyB
      This works for me:
      Code:
      TextBox1.Multiline = True
      TextBox1.MaxLength = 10
      But, if I enter 1, 2, 3, 4 on four lines, one character per line, then I cannot enter any more characters because the newline is included in the character count.

      Or, did you mean that you wanted to set the maximum number of characters per line. You would have to do this manually in the TextChanged event with the split function.

      HTH --Sam
      Thanks SammyB. Am performing server side checking now after reading this article.

      MultilineTextBo x

      Comment

      • SammyB
        Recognized Expert Contributor
        • Mar 2007
        • 807

        #4
        Originally posted by gomzi
        Thanks SammyB. Am performing server side checking now after reading this article.

        MultilineTextBo x
        Ah, you didn't say it was ASP, Glad you found the answer.

        Comment

        Working...