Style 类

定义

注意

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.

组织 ASP.NET 移动控件的样式特征。 有关如何开发 ASP.NET 移动应用程序的信息,请参阅 移动应用 & 具有 ASP.NET 的网站

public ref class Style : ICloneable, System::Web::UI::IParserAccessor, System::Web::UI::IStateManager, System::Web::UI::MobileControls::ITemplateable
[System.ComponentModel.TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))]
public class Style : ICloneable, System.Web.UI.IParserAccessor, System.Web.UI.IStateManager, System.Web.UI.MobileControls.ITemplateable
[System.ComponentModel.TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))]
[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 Style : ICloneable, System.Web.UI.IParserAccessor, System.Web.UI.IStateManager, System.Web.UI.MobileControls.ITemplateable
[<System.ComponentModel.TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))>]
type Style = class
    interface IParserAccessor
    interface ITemplateable
    interface IStateManager
    interface ICloneable
[<System.ComponentModel.TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))>]
[<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 Style = class
    interface IParserAccessor
    interface ITemplateable
    interface IStateManager
    interface ICloneable
Public Class Style
Implements ICloneable, IParserAccessor, IStateManager, ITemplateable
继承
Style
派生
属性
实现

示例

以下示例演示对象中的三个 StyleSheet 用户定义的样式。 对象包含三个 SelectionList 值,这些值对应于三个定义的样式。 命令 OnClick 事件调用 SelectStyle 函数,这会更改 StyleReference 对象的 属性 TextView

<%@ Page Language="C#" 
    Inherits="System.Web.UI.MobileControls.MobilePage" %>
<%@ Register TagPrefix="mobile" 
    Namespace="System.Web.UI.MobileControls" 
    Assembly="System.Web.Mobile" %>

<script runat="server">
    void SelectStyle(object sender, EventArgs e)
    {
        // Retrieve the style name as a string.
        String myStyle = SelectionList1.Selection.ToString();
        // Match the style name and apply the style to TextView1.
        switch (myStyle)
        {
            case "hot":
                TextView1.StyleReference = "Style1";
                break;
            case "medium":
                TextView1.StyleReference = "Style2";
                break;
            case "mild":
                TextView1.StyleReference = "Style3";
                break;
        }
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<body>
<mobile:StyleSheet id="StyleSheet1" runat="server">
    <mobile:Style font-size="Large" font-name="Arial" font-bold="true"
        forecolor="red" font-italic="true" backcolor="#E0E0E0" 
        wrapping="wrap" name="Style1">
    </mobile:Style>
    <mobile:Style font-size="Normal" font-name="Arial" font-bold="false" 
       forecolor="Blue" font-italic="true" backcolor="blue" 
       wrapping="NoWrap" name="Style2">
    </mobile:Style>
    <mobile:Style font-size="Small" font-name="Arial Narrow" 
       font-bold="false" forecolor="Green" font-italic="false" 
       backcolor="Green" wrapping="NoWrap" name="Style3">
    </mobile:Style>
</mobile:StyleSheet>
<mobile:form id="Form1" runat="server">
    <mobile:Label id="Label1" runat="server" Text="Today's Special" 
        StyleReference="title" />
    <mobile:TextView id="TextView1" runat="server" 
        StyleReference="Style1">
        Chili
    </mobile:TextView>
    <mobile:SelectionList runat="server" id="SelectionList1">
        <item Text="hot" Value="hot"/>
        <item Text="medium" Value="medium"/>
        <item Text="mild" Value="mild"/>
    </mobile:SelectionList>
    <mobile:Command runat="server" Text="Select Style" 
        OnClick="SelectStyle" />
    </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" %>

<script runat="server">
    Private Sub SelectStyle(ByVal sender As Object, _
        ByVal e As EventArgs)
        
        ' Retrieve the style name as a string
        Dim myStyle As String = SelectionList1.Selection.ToString()
        ' Match the style name and apply the style to TextView1
        Select Case myStyle
            Case "hot"
                TextView1.StyleReference = "Style1"
            Case "medium"
                TextView1.StyleReference = "Style2"
            Case "mild"
                TextView1.StyleReference = "Style3"
        End Select
    End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<body>
<mobile:StyleSheet id="StyleSheet1" runat="server">
    <mobile:Style font-size="Large" font-name="Arial" font-bold="true"
        forecolor="red" font-italic="true" backcolor="#E0E0E0" 
        wrapping="wrap" name="Style1">
    </mobile:Style>
    <mobile:Style font-size="Normal" font-name="Arial" font-bold="false" 
       forecolor="Blue" font-italic="true" backcolor="blue" 
       wrapping="NoWrap" name="Style2">
    </mobile:Style>
    <mobile:Style font-size="Small" font-name="Arial Narrow" 
       font-bold="false" forecolor="Green" font-italic="false" 
       backcolor="Green" wrapping="NoWrap" name="Style3">
    </mobile:Style>
</mobile:StyleSheet>

<mobile:form id="Form1" runat="server">
    <mobile:Label id="Label1" runat="server" Text="Today's Special" 
        StyleReference="title" />
    <mobile:TextView id="TextView1" runat="server" 
        StyleReference="Style1">
        Chili
    </mobile:TextView>
    <mobile:SelectionList runat="server" id="SelectionList1">
        <item Text="hot" Value="hot"/>
        <item Text="medium" Value="medium"/>
        <item Text="mild" Value="mild"/>
    </mobile:SelectionList>
    <mobile:Command ID="Command1" runat="server" Text="Select Style" 
        OnClick="SelectStyle" />
    </mobile:form>
</body>
</html>

注解

Style 类包含所有移动控件通用的样式特征。 从 Style 类继承的类包含特定于其关联控件的其他样式特征。

由于移动控件支持的设备的多样性,所有样式属性都是公告属性,根据目标设备的功能,可能会采用也可能不遵循。

构造函数

Style()
已过时.

初始化 Style 类的新实例。 此 API 已废弃不用。 有关如何开发 ASP.NET 移动应用程序的信息,请参阅 移动应用 & 具有 ASP.NET 的网站

字段

AlignmentKey
已过时.

表示用于检索 AlignmentStyle 设置的键。 此 API 已废弃不用。 有关如何开发 ASP.NET 移动应用程序的信息,请参阅 移动应用 & 具有 ASP.NET 的网站

BackColorKey
已过时.

用于从 BackColor 属性的嵌入式样式表中检索样式的键。 由 ASP.NET 在内部使用。 此 API 已废弃不用。 有关如何开发 ASP.NET 移动应用程序的信息,请参阅 移动应用 & 具有 ASP.NET 的网站

BoldKey
已过时.

用于从 BoldFont 属性的嵌入式样式表中检索样式的键。 由 ASP.NET 在内部使用。 此 API 已废弃不用。 有关如何开发 ASP.NET 移动应用程序的信息,请参阅 移动应用 & 具有 ASP.NET 的网站

FontNameKey
已过时.

用于从 Name 属性的 Font 属性的嵌入式样式表中检索样式的键。 由 ASP.NET 在内部使用。 此 API 已废弃不用。 有关如何开发 ASP.NET 移动应用程序的信息,请参阅 移动应用 & 具有 ASP.NET 的网站

FontSizeKey
已过时.

用于从 Size 属性的 Font 属性的嵌入式样式表中检索样式的键。 由 ASP.NET 在内部使用。 此 API 已废弃不用。 有关如何开发 ASP.NET 移动应用程序的信息,请参阅 移动应用 & 具有 ASP.NET 的网站

ForeColorKey
已过时.

用于从 ForeColor 属性的嵌入式样式表中检索样式的键。 由 ASP.NET 在内部使用。 此 API 已废弃不用。 有关如何开发 ASP.NET 移动应用程序的信息,请参阅 移动应用 & 具有 ASP.NET 的网站

ItalicKey
已过时.

用于从 Italic 属性的 Font 属性的嵌入式样式表中检索样式的键。 由 ASP.NET 在内部使用。 此 API 已废弃不用。 有关如何开发 ASP.NET 移动应用程序的信息,请参阅 移动应用 & 具有 ASP.NET 的网站

WrappingKey
已过时.

用于从 Wrapping 的嵌入式样式表中检索样式的键。 由 ASP.NET 在内部使用。 此 API 已废弃不用。 有关如何开发 ASP.NET 移动应用程序的信息,请参阅 移动应用 & 具有 ASP.NET 的网站

属性

Alignment
已过时.

获取或设置样式的指定对齐方式。 默认值是 NotSet。 此 API 已废弃不用。 有关如何开发 ASP.NET 移动应用程序的信息,请参阅 移动应用 & 具有 ASP.NET 的网站

BackColor
已过时.

获取或设置样式的指定背景色。 默认值是 Empty。 此 API 已废弃不用。 有关如何开发 ASP.NET 移动应用程序的信息,请参阅 移动应用 & 具有 ASP.NET 的网站

Control
已过时.

返回一个对关联控件的强类型引用。 此 API 已废弃不用。 有关如何开发 ASP.NET 移动应用程序的信息,请参阅 移动应用 & 具有 ASP.NET 的网站

DeviceSpecific
已过时.

获取或设置与控件关联的 DeviceSpecific/Choice 构造。 如果不存在此类构造,则访问器返回 null。 此 API 已废弃不用。 有关如何开发 ASP.NET 移动应用程序的信息,请参阅 移动应用 & 具有 ASP.NET 的网站

Font
已过时.

返回包含有关控件字体信息的 FontInfo 对象。 此 API 已废弃不用。 有关如何开发 ASP.NET 移动应用程序的信息,请参阅 移动应用 & 具有 ASP.NET 的网站

ForeColor
已过时.

获取或设置样式的指定前景色。 此属性通常用于设置文本颜色。 默认值是 Empty。 此 API 已废弃不用。 有关如何开发 ASP.NET 移动应用程序的信息,请参阅 移动应用 & 具有 ASP.NET 的网站

IsTemplated
已过时.

获取一个值,该值指示 Style 对象是否有活动的模板集。 此 API 已废弃不用。 有关如何开发 ASP.NET 移动应用程序的信息,请参阅 移动应用 & 具有 ASP.NET 的网站

IsTrackingViewState
已过时.

获取一个值,该值指示 Style 对象是否保存对其视图状态的更改。 此 API 已废弃不用。 有关如何开发 ASP.NET 移动应用程序的信息,请参阅 移动应用 & 具有 ASP.NET 的网站

Item[Object, Boolean]
已过时.

通过键参数返回样式(可以使用也可以不使用继承)。 此 API 已废弃不用。 有关如何开发 ASP.NET 移动应用程序的信息,请参阅 移动应用 & 具有 ASP.NET 的网站

Item[Object]
已过时.

通过键参数返回样式(可以使用也可以不使用继承)。 此 API 已废弃不用。 有关如何开发 ASP.NET 移动应用程序的信息,请参阅 移动应用 & 具有 ASP.NET 的网站

Name
已过时.

获取或设置指定对象的名称。 默认值为空字符串 ("")。 此 API 已废弃不用。 有关如何开发 ASP.NET 移动应用程序的信息,请参阅 移动应用 & 具有 ASP.NET 的网站

State
已过时.

获取 StateBag 的当前内容。 此 API 已废弃不用。 有关如何开发 ASP.NET 移动应用程序的信息,请参阅 移动应用 & 具有 ASP.NET 的网站

StyleReference
已过时.

获取或设置对 Style 的样式属性的引用。 此 API 已废弃不用。 有关如何开发 ASP.NET 移动应用程序的信息,请参阅 移动应用 & 具有 ASP.NET 的网站

Wrapping
已过时.

获取或设置样式的指定包装模式。 默认值是 NotSet。 此 API 已废弃不用。 有关如何开发 ASP.NET 移动应用程序的信息,请参阅 移动应用 & 具有 ASP.NET 的网站

方法

AddParsedSubObject(Object)
已过时.

DeviceSpecific 属性设置为指定的对象。 此 API 已废弃不用。 有关如何开发 ASP.NET 移动应用程序的信息,请参阅 移动应用 & 具有 ASP.NET 的网站

ApplyTo(WebControl)
已过时.

将样式属性应用到控件。 此 API 已废弃不用。 有关如何开发 ASP.NET 移动应用程序的信息,请参阅 移动应用 & 具有 ASP.NET 的网站

Clone()
已过时.

返回此 Style 对象的实例的一个副本。 此 API 已废弃不用。 有关如何开发 ASP.NET 移动应用程序的信息,请参阅 移动应用 & 具有 ASP.NET 的网站

Equals(Object)
已过时.

确定指定对象是否等于当前对象。

(继承自 Object)
GetHashCode()
已过时.

作为默认哈希函数。

(继承自 Object)
GetTemplate(String)
已过时.

返回具有指定名称的模板。 此 API 已废弃不用。 有关如何开发 ASP.NET 移动应用程序的信息,请参阅 移动应用 & 具有 ASP.NET 的网站

GetType()
已过时.

获取当前实例的 Type

(继承自 Object)
LoadViewState(Object)
已过时.

将视图状态加载到 State 对象的 Style 中。 此 API 已废弃不用。 有关如何开发 ASP.NET 移动应用程序的信息,请参阅 移动应用 & 具有 ASP.NET 的网站

MemberwiseClone()
已过时.

创建当前 Object 的浅表副本。

(继承自 Object)
RegisterStyle(String, Type, Object, Boolean)
已过时.

注册一个样式属性并返回一个用于查找的唯一键。 此 API 已废弃不用。 有关如何开发 ASP.NET 移动应用程序的信息,请参阅 移动应用 & 具有 ASP.NET 的网站

SaveViewState()
已过时.

将对视图状态的更改保存到 Object。 此 API 已废弃不用。 有关如何开发 ASP.NET 移动应用程序的信息,请参阅 移动应用 & 具有 ASP.NET 的网站

ToString()
已过时.

返回表示当前对象的字符串。

(继承自 Object)
TrackViewState()
已过时.

打开 Style 对象中的视图状态跟踪。 此 API 已废弃不用。 有关如何开发 ASP.NET 移动应用程序的信息,请参阅 移动应用 & 具有 ASP.NET 的网站

显式接口实现

IParserAccessor.AddParsedSubObject(Object)
已过时.

有关此成员的说明,请参见 AddParsedSubObject(Object)。 此 API 已废弃不用。 有关如何开发 ASP.NET 移动应用程序的信息,请参阅 移动应用 & 具有 ASP.NET 的网站

IStateManager.IsTrackingViewState
已过时.

有关此成员的说明,请参见 IsTrackingViewState。 此 API 已废弃不用。 有关如何开发 ASP.NET 移动应用程序的信息,请参阅 移动应用 & 具有 ASP.NET 的网站

IStateManager.LoadViewState(Object)
已过时.

有关此成员的说明,请参见 LoadViewState(Object)。 此 API 已废弃不用。 有关如何开发 ASP.NET 移动应用程序的信息,请参阅 移动应用 & 具有 ASP.NET 的网站

IStateManager.SaveViewState()

此 API 支持产品基础结构,不能在代码中直接使用。

已过时.

有关此成员的说明,请参见 SaveViewState()。 此 API 已废弃不用。 有关如何开发 ASP.NET 移动应用程序的信息,请参阅 移动应用 & 具有 ASP.NET 的网站

IStateManager.TrackViewState()
已过时.

有关此成员的说明,请参见 TrackViewState()。 此 API 已废弃不用。 有关如何开发 ASP.NET 移动应用程序的信息,请参阅 移动应用 & 具有 ASP.NET 的网站

适用于

另请参阅