using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls; public partial class Default5 : System.Web.UI.Page
{
static int count = ;
protected void Page_Load(object sender, EventArgs e)
{
Response.Write(count + "Page_Load <br />");
count++;
}
protected override void OnPreInit(EventArgs e)
{
base.OnPreInit(e);
Response.Write(count + "OnPreInit <br />");
count++;
}
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
Response.Write(count + "OnInit <br />");
count++;
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
Response.Write(count + "OnLoad <br />");
count++;
}
protected override void OnPreLoad(EventArgs e)
{
base.OnPreLoad(e);
Response.Write(count + "OnPreLoad <br />");
count++;
}
protected override void OnLoadComplete(EventArgs e)
{
base.OnLoadComplete(e);
Response.Write(count + "OnLoadComplete <br />");
count++;
}
protected override void OnInitComplete(EventArgs e)
{
base.OnInitComplete(e);
Response.Write(count + "OnInitComplete <br />");
count++;
}
protected override void OnUnload(EventArgs e)
{
base.OnUnload(e);
}
protected override void OnDataBinding(EventArgs e)
{
base.OnDataBinding(e);
Response.Write(count + "OnDataBinding <br />");
count++;
}
protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
Response.Write(count + "OnPreRender <br />");
count++;
}
protected void btnGraphics_Click(object sender, EventArgs e)
{
//Bitmap bmp = new Bitmap(10, 10);
//Graphics g = Graphics.FromImage(bmp);
Response.Write(count + "btnGraphics_Click <br />");
count++;
} }

结果为:

0OnPreInit 
1OnInit 
2OnInitComplete 
3OnPreLoad 
4Page_Load 
5OnLoad 
6OnLoadComplete 
7OnPreRender

*session失效或者超时的跳转(站长后台)

判断页面(每个页面调用)

protected override void OnPreInit(EventArgs e)
{
new Users().GetUserInfoCookie(out _mywebhostid, out _myuserid);
if (_myuserid == string.Empty || _mywebhostid == )
{
Response.Redirect("~/login.aspx?reurl=" + HttpUtility.UrlEncode(Request.Url.AbsoluteUri));
}
else
{
new Users().GetUserInfoCookie(out _mywebhostid, out _myuserid);
}
base.OnPreInit(e);
}

登录页面

 string strIp = Request.UserHostAddress;
string strSuccessUrl = Request.QueryString["reurl"] == null ? "~/index.aspx" : HttpUtility.UrlDecode(Request.QueryString["reurl"].ToString()); Users u = new Users();
string loginMsg = u.LoginMsg(strUserId, strPassword, Request.UserHostAddress);
u.LoginMsg2(strUserId, Request.UserHostAddress, Request.UserAgent, ); // 登录跳转到成功页面
if (loginMsg == string.Empty)
{
LoginLog();
Response.Redirect(strSuccessUrl);
}

OnPreInit,OnInit ,OnInitComplete ,OnPreLoad ,Page_Load等执行顺序的更多相关文章

  1. aspx页面Page_Load和aspx页面上控件Page_Load事件执行顺序

    今天公司的同事问了我一个问题,就是页面的Load方法和控件上的Load方法执行顺序的问题,看完了这个图片的递归调用之后大家就笑了,吼吼.

  2. ASP.NET Page执行顺序

    using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Secu ...

  3. .NET页面事件执行顺序

    摘自:http://www.cnblogs.com/kenkofox/archive/2011/03/18/1987998.html和http://blog.csdn.net/yiruoyun/art ...

  4. .NET Page页面事件执行顺序,以及其作用(OnPreInit()、OnInit()等)

    以按钮事件为测试标准 1. OnPreInit //检查 IsPostBack 属性来确定是不是第一次处理该页. //创建或重新创建动态控件. //动态设置主控页. //动态设置 Theme 属性. ...

  5. ASP.NET Page执行顺序如:OnPreInit()、OnInit()

    http://www.cnblogs.com/yeminglong/archive/2012/10/16/2725664.html 当页面进行回发时,如点击按钮,以上事件都会重新执行一次,这时的执行顺 ...

  6. ASP.NET Page执行顺序如:OnPreInit()、OnInit()……

    using System;using System.Data;using System.Configuration;using System.Web;using System.Web.Security ...

  7. asp.net OnInit、OnLoad、Page_Load、Page_Init父子页面执行顺序探究

    本次探究page页面加载的时候,它们的执行顺序 BasePage public class BasePage : Page { public string BaseName { get; set; } ...

  8. 运行page页面时的事件执行顺序

    using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Secu ...

  9. 转:运行page页面时的事件执行顺序及页面的回发与否深度了解

    using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Secu ...

随机推荐

  1. D. Lakes in Berland (DFS或者BFS +连通块

    https://blog.csdn.net/guhaiteng/article/details/52730373 参考题解 http://codeforces.com/contest/723/prob ...

  2. bitset 来计算位

    在stl中提供了 bitset<N> 来计算位,非常方便. 尤其是计算键盘的状态时游泳 ; bitset<> bs = s; cout<<bs[]<<e ...

  3. gitlab自动备份脚本auto_backup_to_remote

    !/bin/bash gitlab 服务器备份路径 LocalBackDir=/var/opt/gitlab/backups 远程备份服务器 gitlab备份文件存放路径 RemoteBackDir= ...

  4. AutoMapper 的简单使用

    var config = new MapperConfiguration( cfg => cfg.CreateMap<SYS_Menu, MenuTreeNode>() .ForMe ...

  5. 2020即将到来!DevExpress Winforms开发有哪些新功能值得期待?

    下载DevExpress v19.2完整版 DevExpress Winforms Controls 内置140多个UI控件和库,完美构建流畅.美观且易于使用的应用程序.DevExpress Winf ...

  6. python-windows安装相关问题

    1.python的环境配置,有些时候是没有配置的,需要在[系统环境]-[path]里添加. 2.安装pip:从官网下载pip包,然后到包目录==>python setup.py install  ...

  7. linux下解决安装jdk后‘环境变量’不生效的问题

    1.是否需要配置环境变量,主要看java -version 显示的版本是否为你期望的版本: (1)不需要配置环境变量的情况 使用java -version查看,版本显示正好是你刚刚安装的版本,这一般为 ...

  8. HDU 6129 - Just do it | 2017 Multi-University Training Contest 7

    比赛时脑子一直想着按位卷积... 按题解的思路: /* HDU 6129 - Just do it [ 规律,组合数 ] | 2017 Multi-University Training Contes ...

  9. FWT 等总结 题解

    目录 与卷积: 代码: 或卷积: 代码: 异或卷积: 代码: FST:子集卷积 代码: 例题: CF914G 代码: uoj310[UNR #2]黎明前的巧克力 代码: CF662C Binary T ...

  10. 在使用Telnet连接localhost时所遇到的问题:出现 ‘telnet’ 不是内部或外部命令,也不是可运行的程序或批处理文件

    1.出现 ‘telnet’ 不是内部或外部命令,也不是可运行的程序或批处理文件.原因:因为本机的Telnet客户端默认是关闭的,所以我们要手动打开解决方案:打开控制面板–>程序–>打开或关 ...