Life Cycle

时间秒杀一切 提交于 2020-02-02 04:46:48
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);
        }

    }

}

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!