Dela via


How to: Set 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 using Visual Web Developer.

To set server controls properties in the designer

  • In Design view, select the control, and then set properties in the Properties window.

    -or-

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

To set server controls properties using ASP.NET syntax

  1. Switch to Source view.

  2. In the control's markup element, set the attribute of the control declaration corresponding to the property you want.

    Note

    In Web server controls, the property names do not necessarily 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="SampleTextBox" type=text runat=server maxlength="20" >
    

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

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

See Also

Tasks

How to: Set HTML Server Control Properties Programmatically

Other Resources

Setting ASP.NET Server Control Properties Programmatically