max length property are not work in textbox asp.net control

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Kanwal jeet

    #1

    max length property are not work in textbox asp.net control

    The max length property are not work in the Asp.Net TextBox control.

    Code:
    <asp:textbox ID="txComment"  MaxLength="20" Width="90%" Columns ="5" Height="100px" TextMode ="MultiLine" runat="server"></asp:textbox>
    Last edited by Frinavale; Nov 8 '10, 02:37 PM. Reason: Added [code] ... [/code] tags.
  • Sandeep M

    #2
    "When the TextMode property of a textbox is set to Multiline the MaxLength property will not limit the maximum length of user input. This is due to the fact that multiline textboxes are rendered to the browser actually as a textarea which has no maxlenth property..."

    you can achieve this by enabling javascript

    Please visit http://forums.asp.net/t/1251514.aspx
    for more details

    Comment

    • jeffstl
      Recognized Expert Contributor
      • Feb 2008
      • 432

      #3
      If you really need multi-line you can also just check the total character count before you save it too (in code) using constants or some other validation if you want to stay away from javascript for whatever reason.

      Since you have your max set to 20 though, I suspect you don't really need multiline ;)

      Comment

      Working...