When the page is postback, such as clicking the button, the above events will be executed again, and the Order of execution is:
1. Onpreinit
2. OnInit
3. Oninitcomplete
4. Onpreload
5. Page_Load
6. OnLoad
7. Button_Click
8. Onloadcomplete
9. OnPreRender
As you can see, the Button_Click event is executed after onload and can be tested:
Public Partial classtestcontrols:system.web.ui.page{Static intCount =0; protected voidPage_Load (Objectsender, EventArgs e) {Response.Write (Count+"Page_Load <br/>"); Count++; } protected Override voidOnpreinit (EventArgs e) {Base. Onpreinit (e); Response.Write (Count+"onpreinit <br/>"); Count++; } protected Override voidOnInit (EventArgs e) {Base. OnInit (e); Response.Write (Count+"OnInit <br/>"); Count++; } protected Override voidOnLoad (EventArgs e) {Base. OnLoad (e); Response.Write (Count+"OnLoad <br/>"); Count++; } protected Override voidonpreload (EventArgs e) {Base. Onpreload (e); Response.Write (Count+"onpreload <br/>"); Count++; } protected Override voidOnloadcomplete (EventArgs e) {Base. Onloadcomplete (e); Response.Write (Count+"onloadcomplete <br/>"); Count++; } protected Override voidOninitcomplete (EventArgs e) {Base. Oninitcomplete (e); Response.Write (Count+"oninitcomplete <br/>"); Count++; } protected Override voidOnUnload (EventArgs e) {Base. OnUnload (e); } protected Override voidondatabinding (EventArgs e) {Base. OnDataBinding (e); Response.Write (Count+"ondatabinding <br/>"); Count++; } protected Override voidOnPreRender (EventArgs e) {Base. OnPreRender (e); Response.Write (Count+"OnPreRender <br/>"); Count++; } protected voidBtngraphics_click (Objectsender, EventArgs e) { //Bitmap bmp = new Bitmap (10, 10); //Graphics g = graphics.fromimage (BMP);Response.Write (Count +"Btngraphics_click <br/>"); Count++; }}
ASP. NET page execution order such as: Onpreinit (), OnInit ()