主题和皮肤
•通过设置站点、页面、控件的指定属性以声明主题
•皮肤 = 控件的可视属性
–存在于后缀名为.skin的文件当中
–默认皮肤以及已命名皮肤
•主题= 单个或者多个皮肤的组合
–物理存储在“Themes”文件夹中
–全局主题以及局部主题
- 在页面中应用主题
<%@ Page Theme="BasicBlue">
- 在站点中应用主题
<configuration> <system.web> <pages theme="BasicBlue" /> </system.web> </configuration>
- 动态应用主题
void Page_PreInit (Object sender, EventArgs e)
{
Page.Theme = " BasicBlue " ;
}
- 全局主题
- 局部主题
- 定义皮肤
代码<!-- Default look for DropDownList controls -->
< asp:DropDownList runat ="server" BackColor ="hotpink" ForeColor ="white" />
<!-- Default look for DataGrid controls -->
< asp:DataGrid runat ="server" BackColor ="#CCCCCC" BorderWidth ="2pt"
BorderStyle ="Solid" BorderColor ="#CCCCCC" GridLines ="Vertical"
HorizontalAlign ="Left" >
< HeaderStyle ForeColor ="white" BackColor ="hotpink" />
< ItemStyle ForeColor ="black" BackColor ="white" />
< AlternatingItemStyle BackColor ="pink" ForeColor ="black" />
</ asp:DataGrid >
...
- 已经命名皮肤
.没有定义SkinID的皮肤为默认皮肤 具有SkinID定义的皮肤为已命名皮肤 每个控件类型必须具有唯一的SkinID Can be defined in same SKIN file as default skins or in separate files 使用控件的 SkinID 属性来应用已命名皮肤
-
定义已命名皮肤
代码<!-- Default look for DropDownList controls -->
< asp:DropDownList runat ="server" BackColor ="blue" ForeColor ="white"
SkinID ="Blue" />
<!-- Default look for DataGrid conotrols -->
< asp:DataGrid runat ="server" BackColor ="#CCCCCC" BorderWidth ="2pt"
BorderStyle ="Solid" BorderColor ="#CCCCCC" GridLines ="Vertical"
HorizontalAlign ="Left" SkinID ="Blue" >
< HeaderStyle ForeColor ="white" BackColor ="blue" />
< ItemStyle ForeColor ="black" BackColor ="white" />
< AlternatingItemStyle BackColor ="lightblue" ForeColor ="black" />
</ asp:DataGrid >
...
-
使用已命名皮肤
< asp:DropDownList ID ="Countries" SkinID ="Blue" RunAt ="server" /> -
EnableTheming属性
所有页面及控件均支持此属性
默认值为 true
将EnableTheming属性设置为false可以为单独的控件或者整个页面禁止主题功能
< asp:DropDownList ID ="Countries" EnableTheming ="false" RunAt ="server" />