在这里我只做两种皮肤的切换,
1.首先要做两个框架结构相同的母板页;
2.新建内容页,引用默认母板页;
3.在新建页面的.cs文件里写上:
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
protected void Page_PreInit(object sender, EventArgs e)
{
if (Request.Cookies["Theme"] != null)
{
this.Theme = Request.Cookies["Theme"].Value;
this.MasterPageFile = "~/" + Request.Cookies["Theme"].Value + ".master";
}
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack && Request.Cookies["Theme"] != null)
this.DropDownList1.SelectedValue = Request.Cookies["Theme"].Value;
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
Response.Cookies["Theme"].Value = DropDownList1.SelectedValue;
Response.Redirect(Request.Url.AbsoluteUri);
}