海滨小城

.net研究

导航

CSS与Theme的作用——Asp.Net

 

学习 2009-12-30 22:19:32 阅读12 评论0   字号: 订阅


 CSS的作用我还是知道的,而且这个东西功能相当强大。
        在VS 2005里出现了一个Theme的东西,与之对应的配置文件是.skin后缀的文件,一般是默认放在网站App_Themes目录下,那它的作用就是对页面上的服务器控件的外观,字体,背景等等进行定义,如果没有指定控件ID,将表示使用该Themes的页面的此类控件都使用这样的外观,确切的说,是主题,如何引用,和CSS一样,在文件顶部调用,CSS文件要有完整、准确的文件路径,Themes却只要指定主题名字,就可以了,就是文件名字。

<%@ Page Language="C#" StylesheetTheme="BasicTheme" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>
    .skin文件的具体定义可以看下面的说明,总之,一类控件共有的属性都可以定义。

<%--
Default skin template. The following skins are provided as examples only.
1. Named control skin. The SkinId should be uniquely defined because
   duplicate SkinId's per control type are not allowed in the same theme.
<asp:GridView runat="server" SkinId="gridviewSkin" BackColor="White" >
   <AlternatingRowStyle BackColor="Blue" />
</asp:GridView>
2. Default skin. The SkinId is not defined. Only one default
   control skin per control type is allowed in the same theme.
<asp:Image runat="server" ImageUrl="~/images/image1.jpg" />
--%>
    还可以在Web.config的<system.web></system.web>里定义所使用的Theme.

 <system.web>
    <pages theme="GridViewTheme" />
</system.web>
     CSS与Theme的组合就是在控件主题定义的时候,通过CSSCLASS里引用所使用的CSS文件了。

posted on 2010-09-07 00:33  海滨小城  阅读(413)  评论(0编辑  收藏  举报