OnPreInit,OnInit ,OnInitComplete ,OnPreLoad ,Page_Load等执行顺序
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等执行顺序的更多相关文章
- aspx页面Page_Load和aspx页面上控件Page_Load事件执行顺序
今天公司的同事问了我一个问题,就是页面的Load方法和控件上的Load方法执行顺序的问题,看完了这个图片的递归调用之后大家就笑了,吼吼.
- ASP.NET Page执行顺序
using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Secu ...
- .NET页面事件执行顺序
摘自:http://www.cnblogs.com/kenkofox/archive/2011/03/18/1987998.html和http://blog.csdn.net/yiruoyun/art ...
- .NET Page页面事件执行顺序,以及其作用(OnPreInit()、OnInit()等)
以按钮事件为测试标准 1. OnPreInit //检查 IsPostBack 属性来确定是不是第一次处理该页. //创建或重新创建动态控件. //动态设置主控页. //动态设置 Theme 属性. ...
- ASP.NET Page执行顺序如:OnPreInit()、OnInit()
http://www.cnblogs.com/yeminglong/archive/2012/10/16/2725664.html 当页面进行回发时,如点击按钮,以上事件都会重新执行一次,这时的执行顺 ...
- ASP.NET Page执行顺序如:OnPreInit()、OnInit()……
using System;using System.Data;using System.Configuration;using System.Web;using System.Web.Security ...
- asp.net OnInit、OnLoad、Page_Load、Page_Init父子页面执行顺序探究
本次探究page页面加载的时候,它们的执行顺序 BasePage public class BasePage : Page { public string BaseName { get; set; } ...
- 运行page页面时的事件执行顺序
using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Secu ...
- 转:运行page页面时的事件执行顺序及页面的回发与否深度了解
using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Secu ...
随机推荐
- linux 确定端口使用情况
lsof -i:3533 确定端口已经在使用
- python 中的 字符串 列表 元祖 字典
str 1 格式化输出 %法 第一种 %s+tuple %d+tuple name = input('请输入你的姓名:') age = input('请输入你的年龄:') hobby = input( ...
- 2019牛客暑期多校训练营(第七场)D Number——实系数多项式因式分解定理
前置知识 代数基本定理 定理:每个次数 ≥ 1 复系数多项式在复数域中至少有一个跟. 由此推出,n次复系数多项式方程在复数域内有且只有n个根(重根按重数计算).(只要不断把多项式除以(x-xa),即可 ...
- Codeforces Round #554 (Div. 2) F2. Neko Rules the Catniverse (Large Version) (矩阵快速幂 状压DP)
题意 有nnn个点,每个点只能走到编号在[1,min(n+m,1)][1,min(n+m,1)][1,min(n+m,1)]范围内的点.求路径长度恰好为kkk的简单路径(一个点最多走一次)数. 1≤n ...
- python--第六天练习题
#1.正则表达式计算 origin = "1 - 2 * ( ( 60 - 30 + ( -40.0 / 5 ) * ( 9 - 2 * 5 / 3 + 7 / 3 * 99 / 4 * 2 ...
- Bluetooth M590 mouse problem Ubuntu
I restart it in the terminal, and it works: Code: $ sudo -i # bluetoothctl [bluetooth]# power off [b ...
- 数据库读写分离、分表分库——用Mycat
转: https://www.cnblogs.com/joylee/p/7513038.html 系统开发中,数据库是非常重要的一个点.除了程序的本身的优化,如:SQL语句优化.代码优化,数据 ...
- 053_修改 Linux 系统的最大打开文件数量
#!/bin/bash#往/etc/security/limits.conf 文件的末尾追加两行配置参数,修改最大打开文件数量为 65536 cat >> /etc/security/li ...
- Druid连接池 属性说明
1.1 maxActive 连接池支持的最大连接数.一般取值20就可以了,一般把maxActive设置成可能的并发量就行了设 0 为没有限制. 1.2 maxIdle 连接池中最多可空闲maxIdle ...
- leetcode解题报告(7):Valid Parentheses
描述 Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the i ...