共用方式為


mobileControls Element (ASP.NET Settings Schema) 

Defines adapter sets that map ASP.NET mobile controls to corresponding adapters within the system.web Element (ASP.NET Settings Schema) section of the Web.config configuration file.

<mobileControls allowCustomAttributes="true|false"
                cookielessDataDictionaryType="System.Web.Mobile.CookielessData"
                sessionStateHistorySize="number">
    <device...>...</device>
</mobileControls>

Attributes and Elements

The following sections describe attributes, child elements, and parent elements.

Attributes

Attribute Description

allowCustomAttributes

Optional Boolean attribute.

Specifies whether mobile controls can have custom attributes.

The default value is false.

cookielessDataDictionaryType

Optional Type attribute.

Defines the type of the dictionary class that maintains the keys for cookieless forms authentication. To turn off this behavior, set the value to an empty string ("").

The default value is CookielessData.

sessionStateHistorySize

Optional Int32 attribute.

Defines the size of the history to use to keep the application view state in the server session.

The default value is 6.

Child Elements

Element Description

device

Defines a new adapter set that maps ASP.NET mobile controls to corresponding adapters within the <system.web> and <mobileControls> sections of the Web.config configuration file.

Parent Elements

Element Description

configuration

The required root element in every configuration file used by the common language runtime and the .NET Framework applications.

system.web

Specifies the root element for the ASP.NET configuration settings in a configuration file. Contains elements that configure ASP.NET Web applications and control how the applications behave.

Remarks

The mobile controls configuration settings also provide general configuration settings for ASP.NET mobile Web Forms pages. All mobile controls allow the developer to set custom control attributes using the IAttributeAccessor interface of the .NET Framework. This interface provides the GetAttribute and SetAttribute methods; in addition, the MobileControl class exposes a dictionary called CustomAttributes. For more information about custom attributes, see the Custom Attributes for Mobile Controls documentation.

For more information about how to create and configure adapters, see the sections in the Adding New Device Adapters and Device Support documentation.

Default Configuration

The following default <mobileControls> element is configured in the root Web.config file in the .NET Framework version 2.0.

<mobileControls sessionStateHistorySize="6" 
  cookielessDataDictionaryType="System.Web.Mobile.CookielessData">
  <device name="XhtmlDeviceAdapters" 
    predicateClass="System.Web.UI.MobileControls.Adapters.XhtmlAdapters.XhtmlPageAdapter" 
    predicateMethod="DeviceQualifies" 
    pageAdapter="System.Web.UI.MobileControls.Adapters.XhtmlAdapters.XhtmlPageAdapter">
      <control name="System.Web.UI.MobileControls.Panel" 
        adapter="System.Web.UI.MobileControls.Adapters.XhtmlAdapters.XhtmlPanelAdapter" />
      <control name="System.Web.UI.MobileControls.Form" 
        adapter="System.Web.UI.MobileControls.Adapters.XhtmlAdapters.XhtmlFormAdapter" />
      <control name="System.Web.UI.MobileControls.TextBox" 
        adapter="System.Web.UI.MobileControls.Adapters.XhtmlAdapters.XhtmlTextBoxAdapter" />
      <control name="System.Web.UI.MobileControls.Label" 
        adapter="System.Web.UI.MobileControls.Adapters.XhtmlAdapters.XhtmlLabelAdapter" />
      <control name="System.Web.UI.MobileControls.LiteralText" 
        adapter="System.Web.UI.MobileControls.Adapters.XhtmlAdapters.XhtmlLiteralTextAdapter" />
      <control name="System.Web.UI.MobileControls.Link" 
        adapter="System.Web.UI.MobileControls.Adapters.XhtmlAdapters.XhtmlLinkAdapter" />
      <control name="System.Web.UI.MobileControls.Command" 
        adapter="System.Web.UI.MobileControls.Adapters.XhtmlAdapters.XhtmlCommandAdapter" />
      <control name="System.Web.UI.MobileControls.PhoneCall" 
        adapter="System.Web.UI.MobileControls.Adapters.XhtmlAdapters.XhtmlPhoneCallAdapter" />
      <control name="System.Web.UI.MobileControls.List" 
        adapter="System.Web.UI.MobileControls.Adapters.XhtmlAdapters.XhtmlListAdapter" />
      <control name="System.Web.UI.MobileControls.SelectionList" 
        adapter="System.Web.UI.MobileControls.Adapters.XhtmlAdapters.XhtmlSelectionListAdapter" />
      <control name="System.Web.UI.MobileControls.ObjectList" 
        adapter="System.Web.UI.MobileControls.Adapters.XhtmlAdapters.XhtmlObjectListAdapter" />
      <control name="System.Web.UI.MobileControls.Image" 
        adapter="System.Web.UI.MobileControls.Adapters.XhtmlAdapters.XhtmlImageAdapter" />
      <control name="System.Web.UI.MobileControls.ValidationSummary" 
        adapter="System.Web.UI.MobileControls.Adapters.XhtmlAdapters.XhtmlValidationSummaryAdapter" />
      <control name="System.Web.UI.MobileControls.Calendar" 
        adapter="System.Web.UI.MobileControls.Adapters.XhtmlAdapters.XhtmlCalendarAdapter" />
      <control name="System.Web.UI.MobileControls.TextView" 
        adapter="System.Web.UI.MobileControls.Adapters.XhtmlAdapters.XhtmlTextViewAdapter" />
      <control name="System.Web.UI.MobileControls.MobileControl" 
        adapter="System.Web.UI.MobileControls.Adapters.XhtmlAdapters.XhtmlControlAdapter" />
      <control name="System.Web.UI.MobileControls.BaseValidator" 
        adapter="System.Web.UI.MobileControls.Adapters.XhtmlAdapters.XhtmlValidatorAdapter" />
  </device>

  <device name="HtmlDeviceAdapters" 
    predicateClass="System.Web.UI.MobileControls.Adapters.HtmlPageAdapter" 
    predicateMethod="DeviceQualifies" 
    pageAdapter="System.Web.UI.MobileControls.Adapters.HtmlPageAdapter">
    <control name="System.Web.UI.MobileControls.Panel" 
      adapter="System.Web.UI.MobileControls.Adapters.HtmlPanelAdapter" />
    <control name="System.Web.UI.MobileControls.Form" 
      adapter="System.Web.UI.MobileControls.Adapters.HtmlFormAdapter" />
      <control name="System.Web.UI.MobileControls.TextBox" 
       adapter="System.Web.UI.MobileControls.Adapters.HtmlTextBoxAdapter" />
      <control name="System.Web.UI.MobileControls.Label" 
        adapter="System.Web.UI.MobileControls.Adapters.HtmlLabelAdapter" />
      <control name="System.Web.UI.MobileControls.LiteralText" 
        adapter="System.Web.UI.MobileControls.Adapters.HtmlLiteralTextAdapter" />
      <control name="System.Web.UI.MobileControls.Link" 
        adapter="System.Web.UI.MobileControls.Adapters.HtmlLinkAdapter" />
      <control name="System.Web.UI.MobileControls.Command" 
        adapter="System.Web.UI.MobileControls.Adapters.HtmlCommandAdapter" />
      <control name="System.Web.UI.MobileControls.PhoneCall" 
        adapter="System.Web.UI.MobileControls.Adapters.HtmlPhoneCallAdapter" />
      <control name="System.Web.UI.MobileControls.List" 
        adapter="System.Web.UI.MobileControls.Adapters.HtmlListAdapter" />
      <control name="System.Web.UI.MobileControls.SelectionList" 
        adapter="System.Web.UI.MobileControls.Adapters.HtmlSelectionListAdapter" />
      <control name="System.Web.UI.MobileControls.ObjectList" 
        adapter="System.Web.UI.MobileControls.Adapters.HtmlObjectListAdapter" />
      <control name="System.Web.UI.MobileControls.Image" 
        adapter="System.Web.UI.MobileControls.Adapters.HtmlImageAdapter" />
      <control name="System.Web.UI.MobileControls.BaseValidator" 
        adapter="System.Web.UI.MobileControls.Adapters.HtmlValidatorAdapter" />
      <control name="System.Web.UI.MobileControls.ValidationSummary" 
        adapter="System.Web.UI.MobileControls.Adapters.HtmlValidationSummaryAdapter" />
      <control name="System.Web.UI.MobileControls.Calendar" 
        adapter="System.Web.UI.MobileControls.Adapters.HtmlCalendarAdapter" />
      <control name="System.Web.UI.MobileControls.TextView" 
        adapter="System.Web.UI.MobileControls.Adapters.HtmlTextViewAdapter" />
      <control name="System.Web.UI.MobileControls.MobileControl" 
        adapter="System.Web.UI.MobileControls.Adapters.HtmlControlAdapter" />
  </device>

  <device name="UpWmlDeviceAdapters" 
    inheritsFrom="WmlDeviceAdapters" 
    predicateClass="System.Web.UI.MobileControls.Adapters.UpWmlPageAdapter" 
    predicateMethod="DeviceQualifies" 
    pageAdapter="System.Web.UI.MobileControls.Adapters.UpWmlPageAdapter">
  </device>

  <device name="WmlDeviceAdapters" 
    predicateClass="System.Web.UI.MobileControls.Adapters.WmlPageAdapter" 
    predicateMethod="DeviceQualifies"
    pageAdapter="System.Web.UI.MobileControls.Adapters.WmlPageAdapter">
    <control name="System.Web.UI.MobileControls.Panel" 
      adapter="System.Web.UI.MobileControls.Adapters.WmlPanelAdapter" />
    <control name="System.Web.UI.MobileControls.Form" 
      adapter="System.Web.UI.MobileControls.Adapters.WmlFormAdapter" />
    <control name="System.Web.UI.MobileControls.TextBox" 
      adapter="System.Web.UI.MobileControls.Adapters.WmlTextBoxAdapter" />
    <control name="System.Web.UI.MobileControls.Label" 
      adapter="System.Web.UI.MobileControls.Adapters.WmlLabelAdapter" />
    <control name="System.Web.UI.MobileControls.LiteralText" 
      adapter="System.Web.UI.MobileControls.Adapters.WmlLiteralTextAdapter" />
    <control name="System.Web.UI.MobileControls.Link" 
      adapter="System.Web.UI.MobileControls.Adapters.WmlLinkAdapter" />
    <control name="System.Web.UI.MobileControls.Command" 
      adapter="System.Web.UI.MobileControls.Adapters.WmlCommandAdapter" />
    <control name="System.Web.UI.MobileControls.PhoneCall" 
      adapter="System.Web.UI.MobileControls.Adapters.WmlPhoneCallAdapter" />
    <control name="System.Web.UI.MobileControls.List" 
      adapter="System.Web.UI.MobileControls.Adapters.WmlListAdapter" />
    <control name="System.Web.UI.MobileControls.SelectionList" 
      adapter="System.Web.UI.MobileControls.Adapters.WmlSelectionListAdapter" />
      <control name="System.Web.UI.MobileControls.ObjectList" 
        adapter="System.Web.UI.MobileControls.Adapters.WmlObjectListAdapter" />
      <control name="System.Web.UI.MobileControls.Image" 
        adapter="System.Web.UI.MobileControls.Adapters.WmlImageAdapter" />
      <control name="System.Web.UI.MobileControls.BaseValidator" 
        adapter="System.Web.UI.MobileControls.Adapters.WmlValidatorAdapter" />
      <control name="System.Web.UI.MobileControls.ValidationSummary" 
        adapter="System.Web.UI.MobileControls.Adapters.WmlValidationSummaryAdapter" />
      <control name="System.Web.UI.MobileControls.Calendar" 
        adapter="System.Web.UI.MobileControls.Adapters.WmlCalendarAdapter" />
      <control name="System.Web.UI.MobileControls.TextView" 
        adapter="System.Web.UI.MobileControls.Adapters.WmlTextViewAdapter" />
      <control name="System.Web.UI.MobileControls.MobileControl" 
        adapter="System.Web.UI.MobileControls.Adapters.WmlControlAdapter" />
  </device>

  <device name="ChtmlDeviceAdapters" 
    inheritsFrom="HtmlDeviceAdapters" 
    predicateClass="System.Web.UI.MobileControls.Adapters.ChtmlPageAdapter"
    predicateMethod="DeviceQualifies" 
    pageAdapter="System.Web.UI.MobileControls.Adapters.ChtmlPageAdapter">
      <control name="System.Web.UI.MobileControls.Form" 
        adapter="System.Web.UI.MobileControls.Adapters.ChtmlFormAdapter" />
      <control name="System.Web.UI.MobileControls.Calendar" 
        adapter="System.Web.UI.MobileControls.Adapters.ChtmlCalendarAdapter" />
      <control name="System.Web.UI.MobileControls.Image" 
        adapter="System.Web.UI.MobileControls.Adapters.ChtmlImageAdapter" />
      <control name="System.Web.UI.MobileControls.TextBox" 
        adapter="System.Web.UI.MobileControls.Adapters.ChtmlTextBoxAdapter" />
      <control name="System.Web.UI.MobileControls.SelectionList" 
        adapter="System.Web.UI.MobileControls.Adapters.ChtmlSelectionListAdapter" />
      <control name="System.Web.UI.MobileControls.Command" 
        adapter="System.Web.UI.MobileControls.Adapters.ChtmlCommandAdapter" />
      <control name="System.Web.UI.MobileControls.PhoneCall" 
        adapter="System.Web.UI.MobileControls.Adapters.ChtmlPhoneCallAdapter" />
      <control name="System.Web.UI.MobileControls.Link" 
        adapter="System.Web.UI.MobileControls.Adapters.ChtmlLinkAdapter" />
  </device>
</mobileControls>

Example

The following example illustrates a control that inherits from the Form class, and provides the ability to raise events or perform other actions after a given timer interval.

<mobileControls>
    <device name="PortalHtmlDeviceAdapters" inheritsFrom="HtmlDeviceAdapters">
        <control name="ASPNetPortal.MobileControls.TabbedPanel, Portal" adapter="ASPNetPortal.MobileControls.HtmlTabbedPanelAdapter,Portal" />
        <control name="ASPNetPortal.MobileControls.LinkCommand, Portal" adapter="ASPNetPortal.MobileControls.HtmlLinkCommandAdapter,Portal" />
    </device>
    <device name="PortalChtmlDeviceAdapters" inheritsFrom="ChtmlDeviceAdapters">
        <control name="ASPNetPortal.MobileControls.TabbedPanel, Portal" adapter="ASPNetPortal.MobileControls.ChtmlTabbedPanelAdapter,Portal" />
    </device>
    <device name="PortalWmlDeviceAdapters" inheritsFrom="WmlDeviceAdapters">
        <control name="ASPNetPortal.MobileControls.TabbedPanel, Portal" adapter="ASPNetPortal.MobileControls.WmlTabbedPanelAdapter,Portal" />
    </device>
</mobileControls>

Element Information

Configuration Section Handler

System.Web.UI.MobileControls.MobileControlsSection

Configuration Member

System.Web.Configuration.SystemWebSectionGroup.MobileControls

Configurable Locations

Machine.config

Root-level Web.config

Application-level Web.config

Virtual or physical directory level Web.config

Requirements

IIS 5.0, IIS 5.1, or IIS 6.0

.NET Framework 1.1, or 2.0

Visual Studio .NET 2003, or Visual Studio 2005

See Also

Tasks

How to: Configure Specific Directories Using Location Settings
How to: Lock ASP.NET Configuration Settings

Reference

system.web Element (ASP.NET Settings Schema)
configuration Element (General Settings Schema)
device Element for mobileControls (ASP.NET Settings Schema)
deviceFilters Element (ASP.NET Settings Schema)
MobileControlsSectionHandler
System.Configuration
System.Web.Configuration

Concepts

ASP.NET Configuration File Hierarchy and Inheritance
Securing ASP.NET Configuration
ASP.NET Configuration Scenarios

Other Resources

Using Device Filters
ASP.NET Mobile Web Pages
Creating ASP.NET Mobile Web Applications
General Configuration Settings (ASP.NET)
ASP.NET Configuration Settings
Configuring ASP.NET Applications
ASP.NET Configuration Files
ASP.NET Configuration API