动态加载主题

 

 <asp:DropDownList ID="ddlSkin" runat="server" AutoPostBack="True">
        <asp:ListItem>None</asp:ListItem>
        <asp:ListItem>gvFirstSkin</asp:ListItem>
        <asp:ListItem>gvSecondSkin</asp:ListItem>
        </asp:DropDownList>
        <asp:GridView ID="gvCatalog" runat="server" AllowPaging="True"
            AutoGenerateColumns="False" DataKeyNames="ID" DataSourceID="SqlDSCatalog">
            <Columns>
                <asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False"
                    ReadOnly="True" SortExpression="ID" />
                <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
                <asp:BoundField DataField="ParentID" HeaderText="ParentID"
                    SortExpression="ParentID" />
                <asp:BoundField DataField="OrderBy" HeaderText="OrderBy"
                    SortExpression="OrderBy" />
                <asp:BoundField DataField="UrlID" HeaderText="UrlID" SortExpression="UrlID" />
            </Columns>
        </asp:GridView>
        <br />
        <asp:SqlDataSource ID="SqlDSCatalog" runat="server"
            ConnectionString="<%$ ConnectionStrings:SQLCONNECTIONSTRING %>"
            SelectCommand="SELECT * FROM [Catalog]"></asp:SqlDataSource>
    </p>

 

 

 

 

 protected void Page_PreInit(object sender, EventArgs e)
    {
        if (Request["ddlSkin"] != null)
        {
            Theme = Request["ddlSkin"].ToString(); //获取当前选择主题
            if (Theme == "None")
            {
                Theme = "";
                gvCatalog.SkinID = "";
            }
            if (Theme != string.Empty)
            {
                gvCatalog.SkinID = Theme.Substring(2);
            }
        }
    }

 

主题是在Page_PreInit(object sender, EventArgs e)事件触发之后立即加载的。因此,如果要动态加载页面的主题,那么至少要在事件Page_PreInit之前动态修改页面主题。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值