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 行動應用程式的資訊,請參閱 mobile Apps & Sites with ASP.NET

C#
[System.ComponentModel.TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))]
public class Style : ICloneable, System.Web.UI.IParserAccessor, System.Web.UI.IStateManager, System.Web.UI.MobileControls.ITemplateable
C#
[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
繼承
Style
衍生
屬性
實作

範例

下列範例示範物件中的三個 StyleSheet 用戶定義樣式。 SelectionList物件會保存三個對應至三個已定義樣式的值。 OnClick命令事件會呼叫 SelectStyle 函式,以變更 StyleReference 對象的屬性TextView

ASP.NET (C#)
<%@ 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>

備註

Style 類包含所有行動控件通用的樣式特性。 繼承自 類別的 Style 類別包含與其相關聯控件特定的其他樣式特性。

由於行動控件支援的裝置多樣性,所有樣式屬性都是諮詢的,而且可能會根據目標裝置的功能而接受或可能不接受。

建構函式

Style()
已淘汰.

初始化 Style 類別的新執行個體。 這個 API 已經過時。 如需如何開發 ASP.NET 行動應用程式的資訊,請參閱 mobile Apps & Sites with ASP.NET

欄位

AlignmentKey
已淘汰.

代表索引鍵,用於擷取 AlignmentStyle 設定。 這個 API 已經過時。 如需如何開發 ASP.NET 行動應用程式的資訊,請參閱 mobile Apps & Sites with ASP.NET

BackColorKey
已淘汰.

BackColor 屬性的內嵌樣式表中擷取樣式所使用的索引鍵。 為 ASP.NET 內部使用。 這個 API 已經過時。 如需如何開發 ASP.NET 行動應用程式的資訊,請參閱 mobile Apps & Sites with ASP.NET

BoldKey
已淘汰.

從內嵌樣式表中擷取樣式所使用的索引鍵,用以設定 BoldFont 屬性。 為 ASP.NET 內部使用。 這個 API 已經過時。 如需如何開發 ASP.NET 行動應用程式的資訊,請參閱 mobile Apps & Sites with ASP.NET

FontNameKey
已淘汰.

針對 Name 屬性的 Font 屬性,從內嵌樣式表中擷取樣式所使用的索引鍵。 為 ASP.NET 內部使用。 這個 API 已經過時。 如需如何開發 ASP.NET 行動應用程式的資訊,請參閱 mobile Apps & Sites with ASP.NET

FontSizeKey
已淘汰.

針對 Size 屬性的 Font 屬性,從內嵌樣式表中擷取樣式所使用的索引鍵。 為 ASP.NET 內部使用。 這個 API 已經過時。 如需如何開發 ASP.NET 行動應用程式的資訊,請參閱 mobile Apps & Sites with ASP.NET

ForeColorKey
已淘汰.

ForeColor 屬性的內嵌樣式表中擷取樣式所使用的索引鍵。 為 ASP.NET 內部使用。 這個 API 已經過時。 如需如何開發 ASP.NET 行動應用程式的資訊,請參閱 mobile Apps & Sites with ASP.NET

ItalicKey
已淘汰.

針對 Italic 屬性的 Font 屬性,從內嵌樣式表中擷取樣式所使用的索引鍵。 為 ASP.NET 內部使用。 這個 API 已經過時。 如需如何開發 ASP.NET 行動應用程式的資訊,請參閱 mobile Apps & Sites with ASP.NET

WrappingKey
已淘汰.

Wrapping 的內嵌樣式表中擷取樣式所使用的索引鍵。 為 ASP.NET 內部使用。 這個 API 已經過時。 如需如何開發 ASP.NET 行動應用程式的資訊,請參閱 mobile Apps & Sites with ASP.NET

屬性

Alignment
已淘汰.

取得或設定樣式的指定對齊方式。 預設值是 NotSet。 這個 API 已經過時。 如需如何開發 ASP.NET 行動應用程式的資訊,請參閱 mobile Apps & Sites with ASP.NET

BackColor
已淘汰.

取得或設定樣式的指定背景色彩。 預設值是 Empty。 這個 API 已經過時。 如需如何開發 ASP.NET 行動應用程式的資訊,請參閱 mobile Apps & Sites with ASP.NET

Control
已淘汰.

傳回關聯控制項的強型別參考。 這個 API 已經過時。 如需如何開發 ASP.NET 行動應用程式的資訊,請參閱 mobile Apps & Sites with ASP.NET

DeviceSpecific
已淘汰.

取得或設定與控制項關聯的 DeviceSpecific/Choice 建構。 如果不存在這類語法結構,存取子 (Accessor) 就會傳回 null。 這個 API 已經過時。 如需如何開發 ASP.NET 行動應用程式的資訊,請參閱 mobile Apps & Sites with ASP.NET

Font
已淘汰.

傳回 FontInfo 物件,該物件包含控制項的字型相關資訊。 這個 API 已經過時。 如需如何開發 ASP.NET 行動應用程式的資訊,請參閱 mobile Apps & Sites with ASP.NET

ForeColor
已淘汰.

取得或設定樣式的指定前景色彩。 通常這個屬性會設定文字的色彩。 預設值是 Empty。 這個 API 已經過時。 如需如何開發 ASP.NET 行動應用程式的資訊,請參閱 mobile Apps & Sites with ASP.NET

IsTemplated
已淘汰.

取得值,指出 Style 物件是否有現用的樣板集。 這個 API 已經過時。 如需如何開發 ASP.NET 行動應用程式的資訊,請參閱 mobile Apps & Sites with ASP.NET

IsTrackingViewState
已淘汰.

取得值,指出 Style 物件是否正在將變更儲存到它的檢視狀態。 這個 API 已經過時。 如需如何開發 ASP.NET 行動應用程式的資訊,請參閱 mobile Apps & Sites with ASP.NET

Item[Object, Boolean]
已淘汰.

使用或不使用繼承,透過金鑰參數傳回樣式。 這個 API 已經過時。 如需如何開發 ASP.NET 行動應用程式的資訊,請參閱 mobile Apps & Sites with ASP.NET

Item[Object]
已淘汰.

透過金鑰參數,使用或不使用繼承來傳回樣式。 這個 API 已經過時。 如需如何開發 ASP.NET 行動應用程式的資訊,請參閱 mobile Apps & Sites with ASP.NET

Name
已淘汰.

取得或設定指定之物件的名稱。 預設值為空字串 ("")。 這個 API 已經過時。 如需如何開發 ASP.NET 行動應用程式的資訊,請參閱 mobile Apps & Sites with ASP.NET

State
已淘汰.

取得 StateBag 的目前內容。 這個 API 已經過時。 如需如何開發 ASP.NET 行動應用程式的資訊,請參閱 mobile Apps & Sites with ASP.NET

StyleReference
已淘汰.

取得或設定 Style 之樣式屬性的參考。 這個 API 已經過時。 如需如何開發 ASP.NET 行動應用程式的資訊,請參閱 mobile Apps & Sites with ASP.NET

Wrapping
已淘汰.

取得或設定樣式的指定換行模式。 預設值是 NotSet。 這個 API 已經過時。 如需如何開發 ASP.NET 行動應用程式的資訊,請參閱 mobile Apps & Sites with ASP.NET

方法

AddParsedSubObject(Object)
已淘汰.

DeviceSpecific 屬性設定為指定的物件。 這個 API 已經過時。 如需如何開發 ASP.NET 行動應用程式的資訊,請參閱 mobile Apps & Sites with ASP.NET

ApplyTo(WebControl)
已淘汰.

將樣式的屬性套用至控制項。 這個 API 已經過時。 如需如何開發 ASP.NET 行動應用程式的資訊,請參閱 mobile Apps & Sites with ASP.NET

Clone()
已淘汰.

傳回 Style 物件這個執行個體的複本。 這個 API 已經過時。 如需如何開發 ASP.NET 行動應用程式的資訊,請參閱 mobile Apps & Sites with ASP.NET

Equals(Object)
已淘汰.

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetHashCode()
已淘汰.

做為預設雜湊函式。

(繼承來源 Object)
GetTemplate(String)
已淘汰.

傳回具有指定名稱的樣板。 這個 API 已經過時。 如需如何開發 ASP.NET 行動應用程式的資訊,請參閱 mobile Apps & Sites with ASP.NET

GetType()
已淘汰.

取得目前執行個體的 Type

(繼承來源 Object)
LoadViewState(Object)
已淘汰.

將檢視狀態載入 State 物件的 Style。 這個 API 已經過時。 如需如何開發 ASP.NET 行動應用程式的資訊,請參閱 mobile Apps & Sites with ASP.NET

MemberwiseClone()
已淘汰.

建立目前 Object 的淺層複製。

(繼承來源 Object)
RegisterStyle(String, Type, Object, Boolean)
已淘汰.

註冊樣式屬性並傳回唯一索引鍵,以便查閱。 這個 API 已經過時。 如需如何開發 ASP.NET 行動應用程式的資訊,請參閱 mobile Apps & Sites with ASP.NET

SaveViewState()
已淘汰.

將檢視狀態的變更儲存至 Object。 這個 API 已經過時。 如需如何開發 ASP.NET 行動應用程式的資訊,請參閱 mobile Apps & Sites with ASP.NET

ToString()
已淘汰.

傳回代表目前物件的字串。

(繼承來源 Object)
TrackViewState()
已淘汰.

開啟 Style 物件中檢視狀態的追蹤。 這個 API 已經過時。 如需如何開發 ASP.NET 行動應用程式的資訊,請參閱 mobile Apps & Sites with ASP.NET

明確介面實作

IParserAccessor.AddParsedSubObject(Object)
已淘汰.

如需這個成員的說明,請參閱 AddParsedSubObject(Object)。 這個 API 已經過時。 如需如何開發 ASP.NET 行動應用程式的資訊,請參閱 mobile Apps & Sites with ASP.NET

IStateManager.IsTrackingViewState
已淘汰.

如需這個成員的說明,請參閱 IsTrackingViewState。 這個 API 已經過時。 如需如何開發 ASP.NET 行動應用程式的資訊,請參閱 mobile Apps & Sites with ASP.NET

IStateManager.LoadViewState(Object)
已淘汰.

如需這個成員的說明,請參閱 LoadViewState(Object)。 這個 API 已經過時。 如需如何開發 ASP.NET 行動應用程式的資訊,請參閱 mobile Apps & Sites with ASP.NET

IStateManager.SaveViewState()

此 API 支援此產品基礎結構,但無法直接用於程式碼之中。

已淘汰.

如需這個成員的說明,請參閱 SaveViewState()。 這個 API 已經過時。 如需如何開發 ASP.NET 行動應用程式的資訊,請參閱 mobile Apps & Sites with ASP.NET

IStateManager.TrackViewState()
已淘汰.

如需這個成員的說明,請參閱 TrackViewState()。 這個 API 已經過時。 如需如何開發 ASP.NET 行動應用程式的資訊,請參閱 mobile Apps & Sites with ASP.NET

適用於

產品 版本 (已過時)
.NET Framework 1.1, 2.0, 3.0, 3.5 (4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1)

另請參閱