Style Class
Organizes style characteristics of an ASP.NET mobile control.
public class System.Web.UI.MobileControls.Style : System.Object,
System.Web.UI.IParserAccessor,
System.Web.UI.MobileControls.ITemplateable,
System.Web.UI.IStateManager
System.ICloneable
Remarks
The base Style class contains style characteristics common to all mobile controls. Classes that inherit from the Style class contain additional style characteristics specific to their associated control.
Due to the diversity of devices supported by mobile controls, all style properties are advisory, and might or might not be honored depending on the capabilities of the target device.
Example
This example demonstrates three user-defined styles in a StyleSheet control. A SelectionList control holds three values that correspond to the three defined styles. The OnClick
command event calls the SelectStyle
function, which changes the StyleReference property of the TextView control.
<%@ 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>
Requirements
Namespace: System.Web.UI.MobileControls
Assembly: System.Web.Mobile
See Also
Name Property