How to set maxlength for multiline TextBox?

前端 未结 7 736
慢半拍i
慢半拍i 2020-12-16 01:51

When using a MultiLine TextBox (which generates a TextArea) setting the MaxLength property has no effect. What is the best workaround? I\'d like to get basic, intended funct

7条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-16 02:06

    If you are using a model object bind to that textbox you can use DataAnnotations attributes to set the maxlength of that property. I'm based on MVC about that but it should work for ASP.NET too!

    This way you don't mess with any Javascript or setting anything in the markup.

提交回复
热议问题