Share via


Style Properties

Some controls support style properties that allow you to set the appearance, such as color and font, of individual elements within the control. To change the appearance of an element, set the properties for the appropriate style object.

<asp:control id="value" runat="server">

   <StyleObject property1="value" 
                property2="value"/>

</asp:control>

Remarks

All style classes derive from the Style class and support the properties defined in the base class. Style classes also implement additional properties specific to the class.

When declaring a Web server control, specify the properties for a particular style object by nesting the element that represents the object (such as <SelectedDayStyle>) between the opening and closing tags of the control. You can then list the individual style properties (such as BackColor="Blue") within the element.

For detailed information about these properties, see the Style Class, TableItemStyle Class, and DataGridPagerStyle Class.

Example

To set the appearance of the selected day in a Calendar Web server control, set the style properties of the SelectedDayStyle style object. The following example demonstrates how to specify a blue background, red text, and Arial font for the selected date in the control. Notice that the Font property belongs to the Calendar control and not the SelectedDayStyle style object.

<asp:Calendar id="Calendar1"
     Font-Name="Arial" 
     runat="server">

   <SelectedDayStyle BackColor="Blue" 
                     ForeColor="Red"/>

</asp:Calendar>

See Also

Web Server Controls | Style Class