次の方法で共有


Device Evaluation Methods 

For ASP.NET mobile controls, device evaluation methods enable you to create named filters that you can use directly in the HasCapability method. You can also use these filters indirectly in the Web.config file, using the <Choice> element of the <DeviceSpecific> section.

To specify a named filter, add an entry to the <deviceFilters> section of the Web.config file. The following example demonstrates defining a device filter named isHTML32.

<filter name="isHTML32" compare="PreferredRenderingType"
  argument="html32" />

At run time, this filter compares the value of the PreferredRenderingType property of the current request's MobileCapabilities instance against the value html32.

The following example illustrates how to define a new capability named GPSEnabled. For more information, see Specifying Fully Qualified Type Names.

namespace MyNamespace
{
    public class MyCapabilityEvaluators
    {
        public static bool IsGPSEnabled(
            System.Web.Mobile.MobileCapabilities capabilities,
             String unusedArg)
        {
            // processing code
        }
    }
}

Add the following element to the appropriate Web.config file to add the new capability:

<deviceFilters>
  <filter name="GPSEnabled" 
    type="MyNamespace.MyCapabilityEvaluators, MyAssembly"
      method="IsGPSEnabled" />
</deviceFilters>

During rendering, one of the choices within a <DeviceSpecific> element is selected based on the capabilities of the target device. The comparison first checks the filter name against filters defined on the page. If a method of the appropriate signature exists in the Web.config file or in the configuration hierarchy, that method is used to evaluate the <Choice> entry for a filter of the appropriate name.

See Also

Reference

Device Capabilities Table
<filter> Element

Concepts

Device Filtering Recommendations
Device-Specific Rendering
Evaluating Capabilities Programmatically