次の方法で共有


Configuring a Web Application for Multiple Devices 

Although ASP.NET mobile Web pages can automatically render appropriate markup to a variety of mobile devices, you can define rendering and handling that are specific to a device or class of devices. A device filter can be used to target a particular subset of devices. It does this by specifying selection criteria based on capabilities of the device. Device filters are stored in the <deviceFilters> section in the Web.config file. You can list common filters in the Web.config file and refer to them by name anywhere in the application.

NoteNote

Device filter names are case sensitive. A filter named isColor is different from a filter named IsColor.

After a device filter is defined, you can apply it in a ASP.NET mobile control to define device-specific rendering. Applied device filters map to <choice> elements inside DeviceSpecific constructs in the .aspx file. You can then set up property overrides and templating for these applied device filters. Some examples of device-specific customizations include:

  • Overriding properties of controls, such as choosing different images for an Image control based on display capabilities.

  • Using different rendering styles for different mobile devices.

  • Using templates for richer rendering on devices such as the Pocket PC.

Each of these scenarios requires filtering based on whether the target device matches a <deviceFilters> section in the Web.config file. These filters also might appear throughout the application, rather than in a single place.

For more information, see Device Filtering Recommendations.

Device Templates

All mobile controls have a default look and layout for a specific device and markup language (for example, HTML, cHTML, or WML). You can manipulate the look and layout by setting properties or by using styles. Some controls also allow you to customize their look by using templates.

A template is a set of elements and controls that make up the layout for a portion of a control for specific markup languages. For example, in the List control, you can define a header or footer template, among others. You can also define a template to format each list item, and you can use a different template to format alternating list items.

NoteNote

Templates differ from styles. Styles specify the appearance of elements such as color and font. Use styles if all you want to do is change the appearance of a control. You can use styles with a template to control the appearance of elements that you define within your templates.

Templates consist of markup language and embedded controls. When the control runs in the mobile Web page, ASP.NET renders the contents of the template in place of the default markup for the control. For more information, see Using Device-Specific Templates.

Some controls allow multiple sets of templates through the <deviceSpecific> and <choice> tags. These multiple sets of templates are called template sets.

Overriding Properties

Your mobile Web pages might require mobile control properties to be set differently depending on the target device. For example, you might want a Label control to have long text on one set of devices and more abbreviated text on another. For each control, you can override properties for each target device.

NoteNote

To set property overrides, you must first define device filters. Use these filters to specify the set of mobile devices for which you want to define custom property values.

See Also

Reference

HasCapability
MobileControl

Concepts

Custom Attributes for Mobile Controls
Device Filtering Recommendations
Device Evaluation Methods
Extended Browser Capabilities