DeviceSpecificChoice 类
定义
注意
The System.Web.Mobile.dll assembly has been deprecated and should no longer be used. For information about how to develop ASP.NET mobile applications, see http://go.microsoft.com/fwlink/?LinkId=157231.
提供 DeviceSpecific/Choice 构造中的单个选择。Provides a single choice within a DeviceSpecific/Choice construct. 若要了解如何开发 ASP.NET 移动应用,请参阅 Mobile Apps & Sites with ASP.NET (ASP.NET 移动应用和网站)。For information about how to develop ASP.NET mobile applications, see Mobile Apps & Sites with ASP.NET.
public ref class DeviceSpecificChoice : System::Web::UI::IAttributeAccessor, System::Web::UI::IParserAccessor
[System.Web.UI.MobileControls.PersistName("Choice")]
public class DeviceSpecificChoice : System.Web.UI.IAttributeAccessor, System.Web.UI.IParserAccessor
[System.Web.UI.MobileControls.PersistName("Choice")]
[System.Obsolete("The System.Web.Mobile.dll assembly has been deprecated and should no longer be used. For information about how to develop ASP.NET mobile applications, see http://go.microsoft.com/fwlink/?LinkId=157231.")]
public class DeviceSpecificChoice : System.Web.UI.IAttributeAccessor, System.Web.UI.IParserAccessor
[<System.Web.UI.MobileControls.PersistName("Choice")>]
type DeviceSpecificChoice = class
interface IParserAccessor
interface IAttributeAccessor
[<System.Web.UI.MobileControls.PersistName("Choice")>]
[<System.Obsolete("The System.Web.Mobile.dll assembly has been deprecated and should no longer be used. For information about how to develop ASP.NET mobile applications, see http://go.microsoft.com/fwlink/?LinkId=157231.")>]
type DeviceSpecificChoice = class
interface IParserAccessor
interface IAttributeAccessor
Public Class DeviceSpecificChoice
Implements IAttributeAccessor, IParserAccessor
- 继承
-
DeviceSpecificChoice
- 属性
- 实现
示例
下面的代码示例演示了 <Choice> 图像中的一个元素。The following code example shows a <Choice> element within an image. Source特性重写 ImageUrl 控件的属性 Image 。The Source attribute overrides the ImageUrl property of the Image control.
尽管该示例使用函数来确定浏览器是否需要 WML (isWML11) 或支持颜色 (supportsColor) ,但你可以改为使用 Web.config 文件来定义一个 <DeviceSpecific> 元素,.NET Framework 会自动使用该元素来做出决定。Although the example uses functions to determine whether the browser requires WML (isWML11) or supports color (supportsColor), you can instead use a Web.config file to define a <DeviceSpecific> element that the .NET Framework automatically uses to make the determination for you.
备注
下面的代码示例使用单文件代码模型,如果直接复制到代码隐藏文件中,则可能无法正常工作。The following code sample uses the single-file code model and may not work correctly if copied directly into a code-behind file. 必须将此代码示例复制到扩展名为 .aspx 的空文本文件中。This code sample must be copied into an empty text file that has an .aspx extension. 有关详细信息,请参阅 ASP.NET Web 窗体页语法概述。For more information, see ASP.NET Web Forms Page Syntax Overview.
<%@ Page Language="C#"
Inherits="System.Web.UI.MobileControls.MobilePage" %>
<%@ Register TagPrefix="mobile"
Namespace="System.Web.UI.MobileControls"
Assembly="System.Web.Mobile" %>
<%@ Import Namespace="System.Web.Mobile" %>
<script runat="server">
private bool supportsColor(MobileCapabilities caps, string optValue)
{
// Determine if the browser is not a Web crawler and
// can display in color
if (!caps.Crawler && caps.IsColor)
return true;
return false;
}
private bool isWML11(MobileCapabilities caps, string optValue)
{
// Determine if the browser is not a Web crawler and
// requires WML markup
if (!caps.Crawler && caps.PreferredRenderingType ==
MobileCapabilities.PreferredRenderingTypeWml11)
return true;
return false;
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<body>
<mobile:form id="form1" runat="server">
<mobile:Image ID="Image1" runat="server"
AlternateText="Cannot display this image.">
<DeviceSpecific>
<choice Filter ="isWML11" ImageURL="wmlImage.wbmp" />
<choice Filter="supportsColor" ImageURL="colorImage.gif" />
<choice ImageURL="monoImg.gif" />
</DeviceSpecific>
</mobile:Image>
</mobile:form>
</body>
</html>
<%@ Page Language="VB"
Inherits="System.Web.UI.MobileControls.MobilePage" %>
<%@ Register TagPrefix="mobile"
Namespace="System.Web.UI.MobileControls"
Assembly="System.Web.Mobile" %>
<%@ Import Namespace="System.Web.Mobile" %>
<script runat="server">
Private Function supportsColor(ByVal caps As MobileCapabilities, _
ByVal value As String) As Boolean
' Determine if the browser is not a Web crawler and
' can display in color
If Not caps.Crawler And caps.IsColor Then
Return True
Else
Return False
End If
End Function
Private Function isWML11(ByVal caps As MobileCapabilities, _
ByVal value As String) As Boolean
' Determine if the browser is not a Web crawler and
' requires WML markup
If (Not caps.Crawler) AndAlso caps.PreferredRenderingType = _
MobileCapabilities.PreferredRenderingTypeWml11 Then
Return True
Else
Return False
End If
End Function
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<body>
<mobile:form id="form1" runat="server">
<mobile:Image ID="Image1" runat="server"
AlternateText="Cannot display this image.">
<DeviceSpecific>
<choice Filter ="isWML11" ImageURL="wmlImage.wbmp" />
<choice Filter="supportsColor" ImageURL="colorImage.gif" />
<choice ImageURL="monoImg.gif" />
</DeviceSpecific>
</mobile:Image>
</mobile:form>
</body>
</html>
注解
此类类似于 <Choice> 元素。This class is analogous to the <Choice> element. 选择按其在元素中出现的顺序进行测试 <DeviceSpecific> 。Choices are tested in the order that they appear within a <DeviceSpecific> element. 如果指定元素的 Filter 属性,则 <Choice> 其值必须为 Machine.config 文件的部分中定义的设备筛选器的名称 <deviceFilters> 。If you specify the Filter property of the <Choice> element, its value must be the name of a device filter defined in the <deviceFilters> section of the Machine.config file. 在运行时,ASP.NET 根据当前设备的功能评估指定的设备筛选器。At run time, ASP.NET evaluates the specified device filter against the capabilities of the current device. 如果成功,则选择此选项。If successful, the choice is selected. 如果未指定 Filter 属性,则会选择元素的默认值 <Choice> 。If you do not specify the Filter property, the defaults for the <Choice> element are selected.
构造函数
| DeviceSpecificChoice() |
初始化 DeviceSpecificChoice 类的新实例。Initializes a new instance of the DeviceSpecificChoice class. 此 API 已废弃不用。This API is obsolete. 若要了解如何开发 ASP.NET 移动应用,请参阅 Mobile Apps & Sites with ASP.NET (ASP.NET 移动应用和网站)。For information about how to develop ASP.NET mobile applications, see Mobile Apps & Sites with ASP.NET. |
属性
| Argument |
获取或设置用于 Filter 属性的参数。Gets or sets the argument used for a Filter property. 默认值为 |
| Contents |
获取为 DeviceSpecific/Choice 构造中的选择定义的重写属性。Gets the overridden properties defined for a choice in a DeviceSpecific/Choice construct. 此 API 已废弃不用。This API is obsolete. 若要了解如何开发 ASP.NET 移动应用,请参阅 Mobile Apps & Sites with ASP.NET (ASP.NET 移动应用和网站)。For information about how to develop ASP.NET mobile applications, see Mobile Apps & Sites with ASP.NET. |
| Filter |
获取或设置设备筛选器的名称。Gets or sets the name of a device filter. 此 API 已废弃不用。This API is obsolete. 若要了解如何开发 ASP.NET 移动应用,请参阅 Mobile Apps & Sites with ASP.NET (ASP.NET 移动应用和网站)。For information about how to develop ASP.NET mobile applications, see Mobile Apps & Sites with ASP.NET. |
| HasTemplates |
获取一个值,该值指示所选元素 < > 中当前选定的选项是否在该元素中定义了模板。Gets a value indicating whether the currently selected choice in the <DeviceSpecific> element has templates defined within it. 此 API 已废弃不用。This API is obsolete. 若要了解如何开发 ASP.NET 移动应用,请参阅 Mobile Apps & Sites with ASP.NET (ASP.NET 移动应用和网站)。For information about how to develop ASP.NET mobile applications, see Mobile Apps & Sites with ASP.NET. |
| Templates |
获取在 < Choice > 元素中定义的模板。Gets the templates that have been defined in the <Choice> element. 此 API 已废弃不用。This API is obsolete. 若要了解如何开发 ASP.NET 移动应用,请参阅 Mobile Apps & Sites with ASP.NET (ASP.NET 移动应用和网站)。For information about how to develop ASP.NET mobile applications, see Mobile Apps & Sites with ASP.NET. |
| Xmlns |
获取或设置 < Choice > 元素中的标记类型。Gets or sets the type of markup in a <Choice> element. 此 API 已废弃不用。This API is obsolete. 若要了解如何开发 ASP.NET 移动应用,请参阅 Mobile Apps & Sites with ASP.NET (ASP.NET 移动应用和网站)。For information about how to develop ASP.NET mobile applications, see Mobile Apps & Sites with ASP.NET. |
方法
| AddParsedSubObject(Object) |
将 Object 添加到 DeviceSpecificChoice 对象的 Templates 对象中。Adds the Object to the DeviceSpecificChoice object's Templates object. 此 API 已废弃不用。This API is obsolete. 若要了解如何开发 ASP.NET 移动应用,请参阅 Mobile Apps & Sites with ASP.NET (ASP.NET 移动应用和网站)。For information about how to develop ASP.NET mobile applications, see Mobile Apps & Sites with ASP.NET. |
| Equals(Object) |
确定指定对象是否等于当前对象。Determines whether the specified object is equal to the current object. (继承自 Object) |
| GetAttribute(String) |
从 DeviceSpecificChoice 对象返回指定的特性。Returns the specified attribute from the DeviceSpecificChoice object. 此 API 已废弃不用。This API is obsolete. 若要了解如何开发 ASP.NET 移动应用,请参阅 Mobile Apps & Sites with ASP.NET (ASP.NET 移动应用和网站)。For information about how to develop ASP.NET mobile applications, see Mobile Apps & Sites with ASP.NET. |
| GetHashCode() |
作为默认哈希函数。Serves as the default hash function. (继承自 Object) |
| GetType() |
获取当前实例的 Type。Gets the Type of the current instance. (继承自 Object) |
| MemberwiseClone() |
创建当前 Object 的浅表副本。Creates a shallow copy of the current Object. (继承自 Object) |
| SetAttribute(String, String) |
将给定的值分配给键指定的特性。Assigns the given value to the attribute specified by the key. 此 API 已废弃不用。This API is obsolete. 若要了解如何开发 ASP.NET 移动应用,请参阅 Mobile Apps & Sites with ASP.NET (ASP.NET 移动应用和网站)。For information about how to develop ASP.NET mobile applications, see Mobile Apps & Sites with ASP.NET. |
| ToString() |
返回表示当前对象的字符串。Returns a string that represents the current object. (继承自 Object) |
显式接口实现
| IAttributeAccessor.GetAttribute(String) |
此 API 支持产品基础结构,不能在代码中直接使用。 有关此成员的说明,请参见 GetAttribute(String)。For a description of this member, see GetAttribute(String). 此 API 已废弃不用。This API is obsolete. 若要了解如何开发 ASP.NET 移动应用,请参阅 Mobile Apps & Sites with ASP.NET (ASP.NET 移动应用和网站)。For information about how to develop ASP.NET mobile applications, see Mobile Apps & Sites with ASP.NET. |
| IAttributeAccessor.SetAttribute(String, String) |
此 API 支持产品基础结构,不能在代码中直接使用。 有关此成员的说明,请参见 SetAttribute(String, String)。For a description of this member, see SetAttribute(String, String). 此 API 已废弃不用。This API is obsolete. 若要了解如何开发 ASP.NET 移动应用,请参阅 Mobile Apps & Sites with ASP.NET (ASP.NET 移动应用和网站)。For information about how to develop ASP.NET mobile applications, see Mobile Apps & Sites with ASP.NET. |
| IParserAccessor.AddParsedSubObject(Object) |
有关此成员的说明,请参见 AddParsedSubObject(Object)。For a description of this member, see AddParsedSubObject(Object). 此 API 已废弃不用。This API is obsolete. 若要了解如何开发 ASP.NET 移动应用,请参阅 Mobile Apps & Sites with ASP.NET (ASP.NET 移动应用和网站)。For information about how to develop ASP.NET mobile applications, see Mobile Apps & Sites with ASP.NET. |