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

[本文档仅供预览,在以后的发行版中可能会发生更改。包含的空白主题用作占位符。]

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

<device name="String" 
        inheritsFrom="String" " 
        pageAdapter="String" 
        predicateClass="String" 
        predicateMethod="String>
    <control.../>
</device>

特性和元素

以下几节描述了特性、子元素和父元素。

特性

特性

说明

name

必选的 String 特性。

指定必须用来标识设备适配器集的唯一名称。

inheritsFrom

可选的 String 特性。

指定该设备适配器集必须继承的设备适配器集。 指定的设备适配器集既可以出现在同一 <mobileControls> 节的前面,也可以出现在更高级别配置文件的 <mobileControls> 节内。

pageAdapter

可选的 String 特性。

为适配器集指定页适配器的类类型。 指定的类必须实现 IPageAdapter 接口。 名称必须符合指定完全限定类型名的 .NET Framework 标准。

ASP.NET 在指定的程序集中搜索该类型。 如果适配器集从另一适配器集继承,则 pageAdapter 特性不是必需的,将默认为父集的值。

predicateClass

可选的 String 特性。

指定提供计算器谓词的类类型。 您用于类类型的名称必须符合指定完全限定类型名的 .NET Framework 标准。

ASP.NET 在指定的程序集中搜索该类型。 如果适配器集从另一类型继承,则 predicateClass 特性不是必需的,将默认为父集的值。

predicateMethod

可选的 String 特性。

指定提供计算器谓词的方法。 此方法必须是静态的,且有如下签名:

static bool EvaluatorMethod(HttpContext context)

如果适配器集从另一适配器集继承,则 predicateMethod 特性不是必需的,将默认为父集的值。

子元素

元素

说明

control

将 ASP.NET 移动控件映射到特定的设备适配器。

父元素

元素

说明

configuration

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

system.web

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

mobileControls

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

备注

如果 <device> 节包含 inheritsFrom 特性,则您不需要声明 predicateClass、predicateMethod 或 pageAdapter 特性。 相反,设备适配器集可以从父设备适配器集定义继承这些属性。

备注

虽然这些特性是不必要的,但您可以在应用程序需要时定义它们。

您可以在适配器集内放置任意数量的控件节或元素,每个节或元素提供特定的控件适配器映射(实现 IControlAdapter 的类)。

默认配置

下面的默认 <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 2003 或 Visual Studio 2005

请参见

任务

How to: Configure Specific Folders Using Location Settings

How to: Lock ASP.NET Configuration Settings

参考

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

configuration 元素(常规设置架构)

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

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

MobileControlsSectionHandler

System.Configuration

System.Web.Configuration

概念

ASP.NET Configuration File Hierarchy

Securing Configuration

Configuration Inheritance

其他资源

Using Device Filters

ASP.NET Mobile Web Pages

Creating ASP.NET Mobile Web Applications

常规配置设置 (ASP.NET)

ASP.NET 配置设置

Configuring ASP.NET Applications

ASP.NET Configuration Files

ASP.NET Configuration API