Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

How to: Set ASP.NET Web Server Control Properties 

Setting a control's properties defines its appearance and behavior. This topic addresses how to set control properties declaratively.

To set server controls properties

  • In the ASP.NET Web page, set the attribute of the control declaration corresponding to the property you want.

    The exact attribute you set depends on the control and the property. For information about the properties for a specific control, search for the name of the control class (for example, "Button class (System.Web.UI.WebControls)" in the Help index.

    The following example shows how to set the MaxLength property of a TextBox control:

    Security noteSecurity Note

    A TextBox accepts user input, which is a potential security threat. By default, ASP.NET Web pages validate that user input does not include script or HTML elements. For more information, see Script Exploits Overview.

    <asp:textbox id="TextBox1" runat=server maxlength=20 />

    In Web server controls, any attribute that does not map to a property of the control is passed as-is to the browser.

See Also

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

© 2014 Microsoft. All rights reserved.