.NET Samples - ASP.NET Style Customization

This section includes the following samples:

Style9 Sample

Style8 Sample

Style2 Sample

Style1 Sample

Style6 Sample

Style4 Sample

Style5 Sample

Style7 Sample

Style3 Sample

Style9 Sample

This sample demonstrates how to programmatically set styles using the ApplyStyle method of the base WebControl class.

Namespaces used in this sample:

System.Drawing; System

Classes used in this sample:

Style; ListItem; TextBox; DropDownList; Button; Page; Object; Port; Control; Import; EventArgs

Style8 Sample

This sample demonstrates using the Attributes collection of a control as a flexible way to set custom styles.

Namespaces used in this sample:

(none)

Classes used in this sample:

ListItem; TextBox; DropDownList; Style; Page; Button; Port; Control

Style2 Sample

This sample demonstrates styles on HTML server controls. CSS defines a class attribute, which can be set to a CSS style definition contained in a <style>...</style> section of the document. The class attribute makes it easy to define styles once and apply them to several tags without having to redefine the style itself.

Namespaces used in this sample:

(none)

Classes used in this sample:

Style; Button; Page; Control

Style1 Sample

This sample illustrates a number of CSS styles applied to various HTML server controls. If you view the source code on the page returned to the client, you will see that these styles are passed along to the browser in the control's rendering.

Namespaces used in this sample:

(none)

Classes used in this sample:

Style; Button; Page; Control

Style6 Sample

This sample demonstrates an alternative syntax for declaring styles as child elements nested within Web server control tags. It is functionally equivalent to the previous Style5 sample.

Namespaces used in this sample:

(none)

Classes used in this sample:

Style; Calendar; Font; Page; Control; Header

Style4 Sample

This sample shows a WebCalendar control with several styles applied to it (a calendar without styles applied is included for contrast). Note that when setting a property that is a class type, such as Font, you need to use the subproperty syntax PropertyName-SubPropertyName.

Namespaces used in this sample:

(none)

Classes used in this sample:

Style; Font; Calendar; Page; Control

Style5 Sample

This sample illustrates using the WebCalendar control. The WebCalendar control exposes many style properties: DayStyle, WeekendDayStyle, TodayDayStyle, SelectedDayStyle, OtherMonthDayStyle, and NextPrevStyle. You can set individual properties of these styles using the subproperty syntax PropertyName-SubPropertyName.

Namespaces used in this sample:

(none)

Classes used in this sample:

Style; Header; Font; Calendar; Page; Control

Style7 Sample

This sample demonstrates how to apply styles to Web server controls using a CSS class definition.

Namespaces used in this sample:

(none)

Classes used in this sample:

Style; Header; Font; Calendar; Page; Control

Style3 Sample

This sample shows how to programmatically manipulate the style for an HTML server control using this Style collection property.

Namespaces used in this sample:

(none)

Classes used in this sample:

Style; Message; Button; Object; EventArgs; String; Page