Export (0) Print
Expand All

Setting ASP.NET Server Control Properties

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

Setting Properties in the Web Forms Designer

The Web Forms Designer provides tools for setting control properties.

To set server controls properties in the designer

  • In Design view, select the control, and then set properties in the Properties window.
  • In HTML view, place the insertion point in the element tag of the control, and then set properties in the Properties window.

Setting Properties using ASP.NET Syntax

Control properties can be set as part of a control's declaration.

To set server controls properties using ASP.NET syntax

  1. Switch to HTML view.
  2. In the .aspx file, 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.

    Note   In Web server controls, the property names do not have the same names as HTML attributes; be sure you are using the correct property name.

    The following example sets the MaxLength property of an HtmlInputText control:   

    <input id="MyTextBox" type=text runat=server maxlength=20 >
    

    The following example sets the TextMode property of a TextBox control:

    <asp:textbox text="Hi" runat=Server TextMode=Multiline />
    

See Also

Setting Web Server Control Properties Programmatically | Setting HTML Server Control Properties Programmatically | Customizing the Appearance of ASP.NET Server Controls Using Styles

Show:
© 2014 Microsoft