Specifying maxlength for multiline textbox

后端 未结 19 2039
感动是毒
感动是毒 2020-11-27 15:21

I\'m trying to use asp:


I want a way to spe

19条回答
  •  抹茶落季
    2020-11-27 16:03

    Things have changed in HTML5:

    ASPX:

    
    

    C#:

    if (!IsPostBack)
    {
        txtBox.Attributes.Add("maxlength", txtBox.MaxLength.ToString());
    }
    

    Rendered HTML:

    
    

    The metadata for Attributes:

    Summary: Gets the collection of arbitrary attributes (for rendering only) that do not correspond to properties on the control.

    Returns: A System.Web.UI.AttributeCollection of name and value pairs.

提交回复
热议问题