温故知新ASP.NET 2.0(C#)(2) - Themes(主题)
[1] 温故知新ASP.NET 2.0(C#)(2) - Themes(主题)
[2] 温故知新ASP.NET 2.0(C#)(2) - Themes(主题)
[3] 温故知新ASP.NET 2.0(C#)(2) - Themes(主题)
[2] 温故知新ASP.NET 2.0(C#)(2) - Themes(主题)
[3] 温故知新ASP.NET 2.0(C#)(2) - Themes(主题)
系列文章导航:
温故知新ASP.NET 2.0(C#)(1) - MasterPage(母版页)
温故知新ASP.NET 2.0(C#)(1) - MasterPage(母版页)
温故知新ASP.NET 2.0(C#)(2) - Themes(主题)
温故知新ASP.NET 2.0(C#)(3) - SiteMap(站点地图)
温故知新ASP.NET 2.0(C#)(4) - 缓存&SqlCacheDependency
温故知新ASP.NET 2.0(C#)(5) - Localization
温故知新ASP.NET 2.0(C#)(8) - DataSourceControl
温故知新ASP.NET 2.0(C#)(6) - Membership&RoleManager
温故知新ASP.NET 2.0(C#)(7) - Profile
温故知新ASP.NET 2.0(C#)(8) - DataSourceControl
主题测试-动态加载主题
Themes/Dynamic.aspx
<%@ Page Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="Dynamic.aspx.cs"
Inherits="Themes_Dynamic" Title="主题测试-动态加载主题" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<p>
相关.skin文件内容如下:<asp:Image runat="server" ImageUrl="Images/pic.jpg" />
</p>
<p>
<a href="?theme=blue">蓝色主题</a> <a href="?theme=red">红色主题</a>
</p>
<p>
该Image控件应用主题中的样式,包括ImageUrl
<br />
<asp:Image ID="img" runat="server" />
</p>
</asp:Content>
Inherits="Themes_Dynamic" Title="主题测试-动态加载主题" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<p>
相关.skin文件内容如下:<asp:Image runat="server" ImageUrl="Images/pic.jpg" />
</p>
<p>
<a href="?theme=blue">蓝色主题</a> <a href="?theme=red">红色主题</a>
</p>
<p>
该Image控件应用主题中的样式,包括ImageUrl
<br />
<asp:Image ID="img" runat="server" />
</p>
</asp:Content>
Themes/Dynamic.aspx.cs
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class Themes_Dynamic : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Page_PreInit(object sender, System.EventArgs e)
{
// 动态修改Page的Theme要在Page_PreInit方法中实现
if (!String.IsNullOrEmpty(Request.QueryString["theme"]))
{
Page.Theme = Request.QueryString["theme"];
}
else
{
Page.Theme = "blue";
}
}
}
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class Themes_Dynamic : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Page_PreInit(object sender, System.EventArgs e)
{
// 动态修改Page的Theme要在Page_PreInit方法中实现
if (!String.IsNullOrEmpty(Request.QueryString["theme"]))
{
Page.Theme = Request.QueryString["theme"];
}
else
{
Page.Theme = "blue";
}
}
}