zoukankan      html  css  js  c++  java
  • 预初始化对象(OnPreInit)

     

    实现功能:动态控制网站程序中服务器控件的外观。

    实现步骤:

    在网站根目录下创建文件夹:App_Themes。这个文件夹名字不能改成别的。

    App_Themes文件夹下创建子文件夹(主题),这个子文件夹名称就是页面的主题名称

    在主题下添加.css,.skin等文件.

    示例:

    1 创建文件夹: App_Themes,在它下面添加两个主题: BlueThemeRedTheme.

    2 BlueTheme下添加文件BlueTheme.skin,写入内容:

    <asp:Button runat="server" BackColor="Blue" ForeColor="White" Font-Name="Arial" Font-Size="9px" />

    3 RedTheme下添加文件RedTheme.skin,写入内容:

    <asp:Button runat="server" BackColor="Red" ForeColor="White" Font-Name="Arial" Font-Size="9px" />

    4 HTML代码:

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="PageLife.aspx.cs" Inherits="PageLife" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml" >

    <head runat="server">

        <title>无标题页</title>

    </head>

    <body>

        <form id="form1" runat="server">

        <div>

        <a href="PageLife.aspx?theme=Red" >red</a>

        <a href="PageLife.aspx?theme=Blue" >blue</a>

        <asp:Button ID="Button1" runat="server" Text="Button" />

        <asp:Button ID="Button2" runat="server" Text="Button" />

        </div>

        </form>

    </body>

    </html>

    5 .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 PageLife : System.Web.UI.Page

    {

        protected void Page_Load(object sender, EventArgs e)

        {

        }

        ///<summary>

        ///预初始化方法,在用户控件和模板页里没有这个事件

        ///</summary>

        ///<param name="e"></param>

        protected override void OnPreInit(EventArgs e)

        {

            //参考http://msdn2.microsoft.com/zh-cn/library/tx35bd89(vs.80).aspx

            base.OnPreInit(e);

            switch (Request.QueryString["theme"])

            {

                case "Blue":

                    Page.Theme = "BlueTheme";

                    break;

                case "Red":

                    Page.Theme = "RedTheme";

                    break;

            }

        }

    }

  • 相关阅读:
    convert image to base64 and post to RESTful wcf
    在android webview实现截屏的手动tounchmove裁剪图片
    How to use jquery ajax and android request security RESTful WCF
    using swfUpload in asp.net mvc
    using HttpClient and sending json data to RESTful server in adroind
    ODP.NET数据访问
    android image watermark
    解决国内不能访问github的问题
    idapro权威指南第二版阅读笔记第九章 交叉引用和绘图功能
    idapro权威指南第二版阅读笔记第二章 逆向和反汇编工具
  • 原文地址:https://www.cnblogs.com/mimengjiangnan/p/947912.html
Copyright © 2011-2022 走看看