关于ASP.Net 2.0中的Theme

1、Theme和CSS的定义
Themes are not the same thing as cascading style sheets.
Cascading style sheets enable you to control the appearance of HTML tags on the browser.
Themes, on the other hand, are applied on the server and they apply to the properties of ASP.NET controls. For example, you can use a theme, but not a cascading style sheet, to specify whether or not a GridView control displays a header or footer.
也就是说Theme针对ASP.Net Server Controls而CSS针对HTML中的Tags

2、Theme(主题)是在后缀名为.skin的皮肤文件中定义的

3、Default Skin和Named Skin
如果ASPX中的Server Control没有指明Control ID,则将应用Default Skin,否则将使用名称一致的Named Skin。注意如果要应用Theme,首先必须ASPX文件的头部即在Page指令中定义Theme,如下所示:
<%@ Page Theme="OrangeTheme" %>

4、将Theme应用到整个应用
在Web.Config文件中加入黑体所示的代码
<configuration>
    <system.web>
  <pages theme="OrangeTheme" />
    </system.web>
</configuration>

5、Theme和StyleSheetTheme
当应用Theme时,Theme中的属性的优先级要高于Server Control中指定属性的优先级。
而通过应用StyleSheetTheme,则可以使Server Control中的属性覆盖StyleSheetTheme中的属性。

6、Theme和CSS
可以将CSS文件放入Theme所在的文件夹,当页面应用Theme时,将自动应用CSS。

7、Theme要比CSS灵活一点,这主要体现在可以通过代码对Theme进行设置和访问。这样就可以很方便地定制用户喜爱的显示方式。
<%@ Page Language="VB" %>
<script runat="server">
    Sub Page_PreInit(ByVal sender As Object, ByVal e As EventArgs)
        Page.Theme = Request("dropTheme")
    End Sub
</script>
<html>
<head id="Head1" runat="server">
    <title>Dynamic Theme</title>
</head>
<body>
    <form id="form1" runat="server">
    
    <asp:DropDownList
        id="dropTheme"
        AutoPostBack="true"
        Runat="Server">
        <asp:ListItem Text="YellowTheme" />
        <asp:ListItem Text="RedTheme" />
    </asp:DropDownList>

    </form>
</body>
</html>


参考网址 Creating Web Application Themes in ASP.NET 2.0




转载于:https://www.cnblogs.com/chinapro/archive/2005/08/14/214689.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值