組織 ASP.NET Mobile 控制項的樣式特性。
public class System.Web.UI.MobileControls.Style : System.Object,
System.Web.UI.IParserAccessor,
System.Web.UI.MobileControls.ITemplateable,
System.Web.UI.IStateManager
System.ICloneable
備註
基底 Style 類別包含所有行動控制項通用的樣式特性。繼承自 Style 類別的類別,包含其關聯控制項的其他樣式字元。
由於行動控制項支援多樣性的裝置,因此所有樣式屬性都須諮詢,並且可能會依據目標裝置的功能判斷是否實行該屬性。
範例
這個範例示範在 StyleSheet 控制項中的三種使用者定義樣式。SelectionList 控制項包含對應至三種定義樣式的三個值。OnClick 命令事件呼叫變更 TextView 控制項中 StyleReference 屬性的 SelectStyle 函式。
<%@ Page Inherits="System.Web.UI.MobileControls.MobilePage"
Language="c#" Debug="true" %>
<script runat=server language="c#">
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>
<mobile:StyleSheet id="StyleSheet1" runat="server">
<Style Font-Size="Large" Font-Name="Arial" Font-Bold="true"
ForeColor="Red" Font-Italic="True" BackColor="#E0E0E0"
Wrapping="Wrap" Name="Style1">
</Style>
<Style Font-Size="Normal" Font-Name="Arial" Font-Bold="false"
ForeColor="Blue" Font-Italic="true" BackColor="blue"
Wrapping="NoWrap" Name="Style2">
</Style>
<Style Font-Size="Small" Font-Name="Arial Narrow"
Font-Bold="false" ForeColor="Green" Font-Italic="false"
BackColor="Green" Wrapping="NoWrap" Name="Style3">
</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>
需求
命名空間:System.Web.UI.MobileControls
**組件:**System.Web.Mobile