代码改变世界

用户控件与应用页面的事件顺序

2009-01-12 10:23  buru  阅读(224)  评论(0)    收藏  举报

1.在WebForm1页面上直接放置用户控件WebUserControl1时的事件顺序:  
  WebUserControl1_Init      
  WebForm1_Init      
  Page_Load    
  WebUserControl1_Load    
  WebForm1_PreRender     
  WebUserControl1_PreRender     
  WebUserControl1_Unload     
  WebForm1_Unload    
    
 2. 在WebForm1页面的Page_Load事件中用代码Load用户控件WebUserControl1时的事件顺序:  
  WebForm1_Init    
  Page_Load     
  WebUserControl1_Init    
  WebUserControl1_Load     
  WebForm1_PreRender      
  WebUserControl1_PreRender    
  WebUserControl1_Unload      
  WebForm1_Unload      
    
  3.在WebForm1页面的Button1_Click事件中用代码Load用户控件WebUserControl1时的事件顺序:  
  WebForm1_Init   
  Page_Load    
  Button1_Click    
  WebUserControl1_Init     
  WebUserControl1_Load     
  WebForm1_PreRender  

  WebUserControl1_PreRender 
  WebUserControl1_Unload     
  WebForm1_Unload