ASP.NET Mobile StyleSheet Control[转]

Definition and Usage
定义和用法

The StyleSheet control defines styles to apply to other controls.
样式表控件的作用是:为控件定义样式。

The StyleSheet control can contain any number of <Style> elements. Each Style element must have a unique name. The name may be used to refer to each Style element from other controls on the same page.
样式表控件可能包含所有的<Style>元素。每个元素必须拥有一个独立的名称。该名称可用于来自同一页面上其它控件的样式元素。

A mobile page can also use an external style sheet. To create an external style sheet, you create a user control and a StyleSheet control in an .ascx file. To refer to this file, you add a StyleSheet control on a page and set its ReferencePath property to the URL of the .ascx file.
一个移动页面可以使用一张外部样式表。你可以在 .aspx 文件中创建用户控件和样式表控件,从而建立外部样式表。你可以在页面上添加样式表控件,并设置其ReferencePath属性的URL为 .ascx 的路径,从而导入外部样式表。


Properties
属性

Property
属性
Value
Description
描述
id unique_name Optional. A unique id for the control
可选参数。为控件指定一个独立的id
ReferencePath URL Optional. Specifies a relative path to an .ascx file that contains a set of style elements
可选参数。指定一个包含一组样式表元素的 .ascx 文件的相对路径
runat "server" Required. Specifies that the control is a server control
必要参数。指定该控件为服务器控件

Example 1
案例1

The following example is an .aspx page with two labels in a form. Each label has a reference to an internal style. The text in the first label will be displayed in bold and the text in the second label will be displayed in red:
下面这个案例是一个在一张表单内包含两个标签的 .aspx 页面。每个标签都有一个连接到内部样式的参数。第一个标签的文本字体将以粗体形式显示,第二个标签的文本字体将以红色显示:

<%@ Page Inherits="System.Web.UI.MobileControls.MobilePage"%>
<%@ Register TagPrefix="Mobile"
Namespace="System.Web.UI.MobileControls"

Assembly="System.Web.Mobile" %>
<Mobile:StyleSheet runat="server">
<Style name="title" Font-Bold="true" />

<Style name="message" ForeColor="red" />
</Mobile:StyleSheet>
<Mobile:Form id="f1" runat="server">

<Mobile:Label runat="server" Text="Hello W3POP!"
StyleReference="title" />
<Mobile:Label runat="server" Text="This is a nice day!"

StyleReference="message" />
</Mobile:Form>

posted on 2009-03-17 17:12  黄裳  阅读(449)  评论(0)    收藏  举报

导航