ASP.NET 生命周期
ASP.NET 生命周期
对于Asp.net页面层开发无论是写页面还是写控件,我觉得都可以用一句话描述:"Do the right thing at the right time in the right place."
本文通过记录页面事件的触发顺序看请求的处理流程,从中可以看出ASP.NET 的生命周期
创建一个网站,在页面上添加一个Label和一个Button,在Default.aspx.cs中修改代码如下:
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class _Default : System.Web.UI.Page
{
protected void Page_PreInit(object sender, EventArgs e)
{
Response.Write("Page_PreInit<br/>");
}
protected void Page_Init(object sender, EventArgs e)
{
Response.Write("Page_Init<br/>");
}
protected void Page_InitComplete(object sender, EventArgs e)
{
Response.Write("Page_InitComplete<br/>");
}
protected void Page_PreLoad(object sender, EventArgs e)
{
Response.Write("Page_PreLoad<br/>");
}
protected void Page_Load(object sender, EventArgs e)
{
Response.Write("Page_Load<br/>");
}
protected void Page_LoadComplete(object sender, EventArgs e)
{
Response.Write("Page_LoadComplete<br/>");
}
protected void Page_PreRender(object sender, EventArgs e)
{
Response.Write("Page_PreRender<br/>");
}
protected void Page_PreRenderComplete(object sender, EventArgs e)
{
Response.Write("Page_PreRenderComplete<br/>");
}
protected void Page_SaveStateComplete(object sender, EventArgs e)
{
Response.Write("Page_SaveStateComplete<br/>");
}
protected void Page_Unload(object sender, EventArgs e)
{
int i = 0;
i++; ////这行代码是用来设置断点的
}
//p
相关文档:
1.Application:用于保存所有用户共用的数据信息。 在Asp.Net中类似的配置数据最好保存在Web.config文件中。如果使用Application对象,一个需要考虑的问题是任何写操作都要在 Application_OnStart事件(global.asax)中完成。尽管使用Application.Lock和 Application.Unlock方法来避免写操作的同步,但是它串行化了Applicat ......
if(MyFile.PostedFile.ContentType != "image/gif"
&& MyFile.PostedFile.ContentType != "image/jpg"
&& MyFile.PostedFile.ContentType != "image/pjpeg"
&& &n ......
net 2.0中的新控件ReportViewer可以方便的制作并显示报表,但是它没有直接支持在网页中的打印。我在分析网页HTML源代码的基础上找到了直接打印的诀窍,先做成一个函数,方便直接使用。
1.包含ReportViewer报表的网页的最终形式HTML DOM结构中,报表被放到一个<iframe>中,其id命名方式为: ......
http://ayic1.blog.163.com/blog/static/27343030200965103528805/
静态变量
当我们编写一个类时,其实就是在描述其对象的属性和行为,而并没有产生实质上的对象,只有通过new关键字才会产生出对象,这时系统才会分配内存空间给对象,其方法才可以供外部调用。
& ......