Compartir a través de


<Style> Element

The <Style> element represents the base Style class, and contains style characteristics common to all ASP.NET mobile controls. Classes that inherit from the Style class contain additional style characteristics specific to their associated control. The <Style> element organizes these style characteristics for a mobile control.

The <Style> element is not a control and it does not inherit from the Form class. You can use a <Style> element only within a StyleSheet control on an ASP.NET mobile Web page.

Every mobile control internally contains a Style object. However, this Style object is not exposed through public interfaces. Instead, there is a publicly accessible property for each characteristic of the style that internally references the privately contained style. For example, the MobileControl class exposes the properties Font-Name, Font-Bold, Font-Size, and so on.

Certain other controls might internally contain an alternative to the Style object. For example, the Form control contains a PagerStyle object that derives from the Style class.

You can also organize styles into a StyleSheet control. Within a style sheet, you can declare any number of style elements. Styles are declared the same way as you declare any control, with the exception that a runat="server" attribute is not required.

A style can reference properties in an external style sheet. For further information about external style sheets, see Creating New Styles.

To have a control acquire its styles from a style object in the style sheet, set the StyleReference property of its style object to the Name of the style by declaring the StyleReference attribute.

Due to the diversity of devices supported by the mobile controls, all style properties are advisory, and might or might not be honored, depending on the capabilities of the target device.

<Style
    Name="name"
    Font-Name="fontName"
    Font-Size={NotSet|normal|small|large}
    Font-Bold={NotSet|false|true}
    Font-Italic="{NotSet|false|true}
    ForeColor="foregroundColor"
    BackColor="backgroundColor"
    Alignment={NotSet|Left|Center|Right}
    Name="uniqueStyleName"
    StyleReference="styleReference"
    Wrapping={NotSet|Wrap|NoWrap}>

    <DeviceSpecific>
        Insert choices here.
    </DeviceSpecific>
</Style>

Properties

Property

Description

Alignment

Sets or returns the alignment of the style, which can be expressed as one of the following Alignment enumerations:

  • Center

  • Left

  • NotSet

  • Right

BackColor

Sets or returns the background color of the control. In a mobile control element, you can set a color value by using standard HTML color identifiers: the name of a color ("Black" or "Red"), or its RGB value expressed as a hexadecimal value ("#ffffff").

Control

Returns the control corresponding to this style object.

DeviceSpecific

Sets or returns the <DeviceSpecific> element contained in this style object.

Font

Returns a FontInfo object containing font information about the control.

ForeColor

Sets or returns The text color of the control. In a mobile control element, you can set a color value by using standard HTML color identifiers: the name of a color ("Black" or "Red"), or its RGB value expressed as a hexadecimal value ("#ffffff").

IsTemplated

Returns true if the style has a <DeviceSelect>/<Choice> construct with a selected choice that has templates.

Item

Returns the style property with the specified name You can return the item either with or without inheritance.

Name

Sets or returns the unique name for the style. This setting is required.

StyleReference

Sets or returns a reference to another Style control. You set this property by referencing the Name of the style you want to use. The default for this property is null.

Wrapping

Sets or returns whether the text wraps to the next line, which can be expressed as one of the following Wrapping enumerations:

  • NotSet

  • NoWrap

  • Wrap

Containment Rules

The following controls can contain a <Style> element.

Control

Comments

System.Web.UI.MobileControls.StyleSheet

A StyleSheet control can contain any number of <Style> elements.

A <Style> element can contain the following controls.

Control

Comments

System.Web.UI.MobileControls.DeviceSpecific

A <Style> element can contain zero or one DeviceSpecific controls.

See Also

Reference

Style

Concepts

Device-Specific Rendering

Styles

Other Resources

Creating New Styles