mobileControls 元素(ASP.NET 设置架构)

更新:2007 年 11 月

定义适配器集,以将 ASP.NET 移动控件映射到 Web.config 配置文件的 system.web 元素(ASP.NET 设置架构) 节中的相应适配器。

configuration 元素(常规设置架构)
  system.web 元素(ASP.NET 设置架构)
    mobileControls 元素(ASP.NET 设置架构)

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

属性和元素

下面几部分描述了属性、子元素和父元素。

属性

属性

说明

allowCustomAttributes

可选的 Boolean 属性。

指定移动控件是否可以具有自定义属性。

默认值为 false。

cookielessDataDictionaryType

可选的 Type 属性。

定义字典类的类型,该类维护无 Cookie 的 Forms 身份验证的密钥。若要禁用此行为,请将该值设置为空字符串 ("")。

默认值为 CookielessData

sessionStateHistorySize

可选的 Int32 属性。

定义用于在服务器会话中保存应用程序视图状态的历史记录的大小。

默认值为 6。

子元素

元素

说明

device

在 Web.config 配置文件的 <system.web> 和 <mobileControls> 节内定义将 ASP.NET 移动控件映射到相应适配器的新适配器集。

父元素

元素

说明

configuration

公共语言运行库和 .NET Framework 应用程序所使用的每个配置文件中均需要的根元素。

system.web

指定配置文件中 ASP.NET 配置设置的根元素。包含各种元素,这些元素配置 ASP.NET Web 应用程序并控制这些应用程序的行为方式。

备注

移动控件配置设置还为 ASP.NET 移动 Web 窗体页提供了常规配置设置。所有移动控件都允许开发人员通过使用 .NET Framework 的 IAttributeAccessor 接口设置自定义控件属性。此接口提供 GetAttributeSetAttribute 方法;此外,MobileControl 类还公开一个名为 CustomAttributes 的字典。有关自定义属性的更多信息,请参见移动控件的自定义属性文档。

有关如何创建和配置适配器的更多信息,请参见添加新的设备适配器和设备支持文档中的各部分。

默认配置

下面的默认 <mobileControls> 元素在 .NET Framework 2.0 版的根 Web.config 文件中配置。

<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>

示例

下面的示例阐释一个控件,该控件从 Form 类继承,并能够在给定的计时器间隔后引发事件或者执行其他操作。

<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>

元素信息

Configuration Section Handler

System.Web.UI.MobileControls.MobileControlsSection

Configuration Member

SystemWebSectionGroup.MobileControls

Configurable Locations

Machine.config

根级别的 Web.config

应用程序级别的 Web.config

虚拟或物理目录级别的 Web.config

Requirements

IIS 5.0、IIS 5.1 或 IIS 6.0

.NET Framework 1.1 或 2.0

Visual Studio .NET 2003 或 Visual Studio 2005

请参见

任务

如何:使用位置设置配置特定目录

如何:锁定 ASP.NET 配置设置

概念

ASP.NET 配置文件层次结构和继承

保证 ASP.NET 配置的安全

ASP.NET 配置方案

参考

system.web 元素(ASP.NET 设置架构)

configuration 元素(常规设置架构)

mobileControls 的 device 元素(ASP.NET 设置架构)

deviceFilters 元素(ASP.NET 设置架构)

MobileControlsSectionHandler

System.Configuration

System.Web.Configuration

其他资源

使用设备筛选器

ASP.NET 移动网页

创建 ASP.NET 移动网页

常规配置设置 (ASP.NET)

ASP.NET 配置设置

管理 ASP.NET 网站

ASP.NET 配置文件

ASP.NET 配置 API