using System;
using System.Collections;
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;
using System.Collections.Specialized;
using System.Diagnostics;
[ToolboxData("<{0}:LifeCycle runat=server></{0}:LifeCycle>")]
public partial class LifeCycle : UserControl, IPostBackEventHandler, IPostBackDataHandler
{
protected override void OnInit(System.EventArgs e)
{
Trace("Lifecycle: Init Event.");
base.OnInit(e);
}
protected override void TrackViewState()
{
Trace("Lifecycle: Track ViewState.");
base.TrackViewState();
}
protected override void LoadViewState(object savedState)
{
Trace("Lifecycle: Load ViewState Event.");
base.LoadViewState(savedState);
}
protected override void LoadControlState(object savedState)
{
Trace("Lifecycle: Load ControlState Event.");
base.LoadControlState(savedState);
}
public override void DataBind()
{
Trace("Lifecycle: DataBind Event.");
base.DataBind();
}
public bool LoadPostData(string postDataKey, NameValueCollection postCollection)
{
Trace("Lifecycle: Load PostBack Data Event.");
Page.RegisterRequiresRaiseEvent(this);
return true;
}
protected override void OnLoad(System.EventArgs e)
{
Trace("Lifecycle: Load Event.");
base.OnLoad(e);
}
public void RaisePostDataChangedEvent()
{
Trace("Lifecycle: Post Data Changed Event.");
}
public void RaisePostBackEvent(string argument)
{
Trace("Lifecycle: PostBack Event.");
}
protected override void OnPreRender(System.EventArgs e)
{
Trace("Lifecycle: PreRender Event.");
Page.RegisterRequiresPostBack(this);
base.OnPreRender(e);
}
protected override object SaveViewState()
{
Trace("Lifecycle: Save ViewState.");
return base.SaveViewState();
}
protected override object SaveControlState()
{
Trace("Lifecycle: Save ControlState.");
return base.SaveControlState();
}
protected override void Render(HtmlTextWriter writer)
{
base.Render(writer);
Trace("Lifecycle: Render Event.");
writer.Write("<h3>LifeCycle Control</h3>");
}
protected override void OnUnload(System.EventArgs e)
{
Trace("Lifecycle: Unload Event.");
base.OnUnload(e);
}
public override void Dispose()
{
Trace("Lifecycle: Dispose Event.");
base.Dispose();
}
private void Trace(string info)
{
if (Context != null)
{
Context.Trace.Warn(info);
Debug.WriteLine(info);
}
}
}
using System.Collections;
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;
using System.Collections.Specialized;
using System.Diagnostics;
[ToolboxData("<{0}:LifeCycle runat=server></{0}:LifeCycle>")]
public partial class LifeCycle : UserControl, IPostBackEventHandler, IPostBackDataHandler
{
protected override void OnInit(System.EventArgs e)
{
Trace("Lifecycle: Init Event.");
base.OnInit(e);
}
protected override void TrackViewState()
{
Trace("Lifecycle: Track ViewState.");
base.TrackViewState();
}
protected override void LoadViewState(object savedState)
{
Trace("Lifecycle: Load ViewState Event.");
base.LoadViewState(savedState);
}
protected override void LoadControlState(object savedState)
{
Trace("Lifecycle: Load ControlState Event.");
base.LoadControlState(savedState);
}
public override void DataBind()
{
Trace("Lifecycle: DataBind Event.");
base.DataBind();
}
public bool LoadPostData(string postDataKey, NameValueCollection postCollection)
{
Trace("Lifecycle: Load PostBack Data Event.");
Page.RegisterRequiresRaiseEvent(this);
return true;
}
protected override void OnLoad(System.EventArgs e)
{
Trace("Lifecycle: Load Event.");
base.OnLoad(e);
}
public void RaisePostDataChangedEvent()
{
Trace("Lifecycle: Post Data Changed Event.");
}
public void RaisePostBackEvent(string argument)
{
Trace("Lifecycle: PostBack Event.");
}
protected override void OnPreRender(System.EventArgs e)
{
Trace("Lifecycle: PreRender Event.");
Page.RegisterRequiresPostBack(this);
base.OnPreRender(e);
}
protected override object SaveViewState()
{
Trace("Lifecycle: Save ViewState.");
return base.SaveViewState();
}
protected override object SaveControlState()
{
Trace("Lifecycle: Save ControlState.");
return base.SaveControlState();
}
protected override void Render(HtmlTextWriter writer)
{
base.Render(writer);
Trace("Lifecycle: Render Event.");
writer.Write("<h3>LifeCycle Control</h3>");
}
protected override void OnUnload(System.EventArgs e)
{
Trace("Lifecycle: Unload Event.");
base.OnUnload(e);
}
public override void Dispose()
{
Trace("Lifecycle: Dispose Event.");
base.Dispose();
}
private void Trace(string info)
{
if (Context != null)
{
Context.Trace.Warn(info);
Debug.WriteLine(info);
}
}
}
来源:https://www.cnblogs.com/aspxphpjsprb/archive/2008/06/13/1220893.html