共用方式為


Applying Device Filters 

After you define a device filter, you can add it to the list of applied filters for a control. Applying filters to controls enables the use of property override values and templates.

To apply a device filter

  1. Select the control to which the filter will be applied.

  2. In the Properties window, click the ellipsis button (ASP.NET Mobile Designer ellipse) in the AppliedDeviceFilters box.

    The Applied Device Filters dialog box is displayed. The Available Device Filters lists includes all the device filters defined at the application level.

  3. Do one of the following:

    • Select a device filter that you want to use.

    • Enter the name of an evaluator-delegate method defined in the ASP.NET mobile Web page.

  4. Click Add To List.

    The selected device filter or method name is added to the Applied Device Filters list.

  5. In the Applied Device Filters list, click the new device filter.

  6. In the Argument box, enter any optional device filter argument. For comparison filters, the argument replaces the value defined in the Device Filter Editor dialog box and saved in the Web.config file. For delegate-based filters, the argument is passed to the method. If no argument is specified, a null value is used.

    NoteNote

    ASP.NET mobile controls distinguish device filters by using both the name and argument value of each filter. As a result, two device filters can have the same name if they have different argument values.

  7. If required, reorder the applied device filters using the arrow buttons.

    At run time, the application tests the filters one by one from the top to the bottom. The first device filter that results in a successful evaluation determines which property overrides or templates the application uses.

    NoteNote

    The applied device filter named Default always results in a successful evaluation. If present, this filter blocks all other evaluations below it in the list. This filter therefore appears as the last device filter in the Applied Device Filters list. Applications can use the Default filter to catch every device not matching any of the filters above it in the list.

  8. Click OK.

See Also

Tasks

How to: Configure Device Filters

Concepts

Introduction to Device Filters
Defining Device Filters
Overriding Properties

Other Resources

Customizing ASP.NET Mobile Web Controls for Specific Devices
Customizing with Control Templates