net5:Theme主题样式的动态变换,在内容页content中操作影响模板页的操作

原文发布时间为:2008-07-29 —— 来源于本人的百度文章 [由搬家工具导入]

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 Default2 : System.Web.UI.Page
{
    protected void Page_PreInit(object sender, EventArgs e)
    {
        if (Request.QueryString["t"] != null)
        {
            Page.Theme = Request.QueryString["t"].ToString();
        }
    }
   
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Response.Redirect("Default2.aspx?t=blue");
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        Response.Redirect("Default2.aspx?t=red");
    }
}

---------------------------------------------------------------------------

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 _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        ((Label)(Master.FindControl("Label1"))).Text = DropDownList1.SelectedValue;
        Label1.Text = DropDownList1.SelectedValue;
    }
}

---------

App_Themes文件夹中的blue文件夹文件SkinFile文件内容如下:

<asp:GridView runat="server" AutoGenerateColumns="False"
            CellPadding="4" DataKeyNames="au_id" ForeColor="#333333"
            GridLines="None">
            <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
            <Columns>
                <asp:BoundField DataField="au_id" HeaderText="au_id" ReadOnly="True" SortExpression="au_id" />
                <asp:BoundField DataField="au_lname" HeaderText="au_lname" SortExpression="au_lname" />
                <asp:BoundField DataField="au_fname" HeaderText="au_fname" SortExpression="au_fname" />
            </Columns>
            <RowStyle BackColor="#EFF3FB" />
            <EditRowStyle BackColor="#2461BF" />
            <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
            <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
            <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
            <AlternatingRowStyle BackColor="White" />
        </asp:GridView>
       
       
        <asp:GridView SkinId="pifu" runat="server" CellPadding="4" ForeColor="#333333" GridLines="None">
            <FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
            <RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
            <SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
            <PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" />
            <HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
            <AlternatingRowStyle BackColor="White" />
        </asp:GridView>
       
       <asp:ListBox runat="server" BackColor="Blue" Font-Bold="True" Font-Italic="True"
            Font-Names="Arial Black">
            <asp:ListItem>fgh</asp:ListItem>
            <asp:ListItem Value="gf">jdf</asp:ListItem>
            <asp:ListItem>dfgh</asp:ListItem>
        </asp:ListBox>

StyleSheet文件内容如下:

body
{
color: blue;
font-style: italic;
font-family: 'Arial Black';
background-color: #ff33ff;
}

-----------------------

App_Themes文件夹中的red文件夹文件SkinFile文件内容类似

原文地址:https://www.cnblogs.com/handboy/p/7141607.html