Page_PreInit

来源:互联网 发布:无极树如何实现php 编辑:程序博客网 时间:2024/05/22 06:05

 Page_PreInit

在回发数据已加载到页服务器控件之后但在 OnLoad 事件之前,引发PreLoad 事件。

在调用 OnPreInit方法后,将加载个性化信息并初始化页主题(如果有)。这也是为页动态定义 PageThemeMasterPage 的首选阶段。

 

我页面传值都是在Page_Load事件里进行的,其实Page_PreInit事件里也完全可以做到的,下面是代码:

    int SubId = 0;
    string SessionName;
    protected void Page_PreInit(object sender, EventArgs e)
    {
        if (Request.Params["SubId"] != null && Request.Params["SubId"].Length > 0)
        {
            SubId = int.Parse(Request.Params["SubId"]);
        }
        else
        {
            Response.Redirect("Error.aspx");      
        }

        SessionName = Session["name"].ToString();
        if (SessionName == "" || SessionName == null)
        {//判断是否登录
            Response.Redirect("Error.aspx");

        }
    }
可能这个对很多ASPNET爱好者来说是最基础的东西,恳请大家多多指点,呵呵

原创粉丝点击