control控件生命周期内各种方法执行顺序

OnInit
TrackViewState
OnLoad
EnsureChildControls
CreateChildControls
OnPreRender
SaveViewState
Render
RenderChildren
OnUnload

试验程序:
using System;
using System.Data;
using System.Data.OleDb;
using System.Web;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Web.UI;
using System.IO;
using System.ComponentModel;

namespace ku1
{
 /// <summary>
 /// te 的摘要说明。
 /// </summary>
 [DefaultProperty("Text"),
  ToolboxData("<{0}:te runat=server></{0}:te>")]
 public class te : System.Web.UI.WebControls.WebControl,INamingContainer
 {
  private string text;
 
  [Bindable(true),
   Category("Appearance"),
   DefaultValue("")]
  public string Text
  {
   get
   {
    return text;
   }

   set
   {
    text = value;
   }
  }

  /// <summary>
  /// 将此控件呈现给指定的输出参数。
  /// </summary>
  /// <param name="output"> 要写出到的 HTML 编写器 </param>
  
  protected override void CreateChildControls()
  {
   HttpContext.Current.Response.Write("CreateChildControls<br>"); 
   base.CreateChildControls();
  }
  public override void DataBind()
  {
   HttpContext.Current.Response.Write("DataBind()<br>"); 
   base.DataBind() ;
  }
  
  protected override void AddParsedSubObject(object obj)

  {
   HttpContext.Current.Response.Write("AddParsedSubObject<br>"); 
   base.AddParsedSubObject(obj);
  }
  protected override ControlCollection CreateControlCollection()

  {
   HttpContext.Current.Response.Write("CreateControlCollection<br>"); 
    return base.CreateControlCollection();
  }
  protected override void EnsureChildControls()

  {
   HttpContext.Current.Response.Write("EnsureChildControls<br>"); 
   base.EnsureChildControls();
  }
  public override bool HasControls()

  {
   HttpContext.Current.Response.Write("HasControls<br>"); 
    return base.HasControls();
  }
  protected override void LoadViewState(object savedState)

  {
   HttpContext.Current.Response.Write("LoadViewState<br>"); 
   base.LoadViewState(savedState);
  }
  protected override bool OnBubbleEvent(object source, EventArgs args)
  {
   HttpContext.Current.Response.Write("OnBubbleEvent<br>"); 
    return base.OnBubbleEvent(source,args);
  }
  protected override void OnDataBinding(EventArgs e)

  {
   HttpContext.Current.Response.Write("OnDataBinding<br>"); 
   base.OnDataBinding(e);
  }
  protected override void OnInit(EventArgs e)
  {
   HttpContext.Current.Response.Write("OnInit<br>"); 
   base.OnInit(e);
  }
  protected override void OnLoad(EventArgs e)
  {
   HttpContext.Current.Response.Write("OnLoad<br>"); 
   base.OnLoad(e);
  }
  protected override void OnPreRender(EventArgs e)
  {
   HttpContext.Current.Response.Write("OnPreRender<br>"); 
   base.OnPreRender(e);
  }
  protected override void OnUnload(EventArgs e)
   {
    HttpContext.Current.Response.Write("OnUnload<br>"); 
    base.OnUnload(e);
   }
  protected override void RemovedControl(Control control)

    {
     HttpContext.Current.Response.Write("RemovedControl<br>"); 
     base.RemovedControl(control);
    }
  protected override void Render(HtmlTextWriter writer)
  {
   HttpContext.Current.Response.Write("Render<br>"); 
   base.Render(writer);
  }
  protected override void RenderChildren(HtmlTextWriter writer)
  {
   HttpContext.Current.Response.Write("RenderChildren<br>"); 
   base.RenderChildren(writer);
  }
  protected override object SaveViewState()

  {
   HttpContext.Current.Response.Write("SaveViewState<br>"); 
    return base.SaveViewState();
  }
  protected override void TrackViewState()
  {
   HttpContext.Current.Response.Write("TrackViewState<br>"); 
   base.TrackViewState();
  }

 }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值