探Button控件的Click事件发生始末

先贴结果图:

点击后:

页面代码:

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Label ID="Label1" runat="server" Text=""></asp:Label>
        <hr />
        <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
    </div>
    </form>
</body>
</html>

  

public partial class _Default : System.Web.UI.Page
{
    Stopwatch watch = new Stopwatch();
    public _Default()
    {
        watch.Start();
    }
    protected void Page_PreInit(object sender, EventArgs e)
    {
        Response.Write(watch.ElapsedTicks + ": Page_PreInit<br/>");
        Label1.Text += watch.ElapsedTicks + ": Page_PreInit<br/>";
    }
    protected void Page_Init(object sender, EventArgs e)
    {
        //System.Threading.Thread.Sleep(1000);
        Response.Write(watch.ElapsedTicks + ": Page_Init<br/>");
        Label1.Text += watch.ElapsedTicks + ": Page_Init<br/>";
    }
    protected void Page_InitComplete(object sender, EventArgs e)
    {
        Response.Write(watch.ElapsedTicks + ": Page_InitComplete<br/>");
        Label1.Text += watch.ElapsedTicks + ": Page_InitComplete<br/>";
    }
    protected void Page_PreLoad(object sender, EventArgs e)
    {
        Response.Write(watch.ElapsedTicks + ": Page_PreLoad<br/>");
        Label1.Text += watch.ElapsedTicks + ": Page_PreLoad<br/>";
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        Response.Write(watch.ElapsedTicks + ": Page_Load<br/>");
        Label1.Text += watch.ElapsedTicks + ": Page_Load<br/>";
    }
    protected void Page_LoadComplete(object sender, EventArgs e)
    {
        Response.Write(watch.ElapsedTicks + ": Page_LoadComplete<br/>");
        Label1.Text += watch.ElapsedTicks + ": Page_LoadComplete<br/>";
    }
    protected void Page_PreRender(object sender, EventArgs e)
    {
        Response.Write(watch.ElapsedTicks + ": Page_PreRender<br/>");
        Label1.Text += watch.ElapsedTicks + ": Page_PreRender<br/>";
    }
    protected void Page_PreRenderComplete(object sender, EventArgs e)
    {
        Response.Write(watch.ElapsedTicks + ": Page_PreRenderComplete<br/>");
        Label1.Text += watch.ElapsedTicks + ": Page_PreRenderComplete<br/>";
    }
    protected void Page_SaveState(object sender, EventArgs e)
    {
        Response.Write(watch.ElapsedTicks + ": Page_SaveState<br/>");
        Label1.Text += watch.ElapsedTicks + ": Page_SaveState<br/>";
    }
    protected void Page_SaveStateComplete(object sender, EventArgs e)
    {
        Response.Write(watch.ElapsedTicks + ": Page_SaveStateComplete<br/>");
        Label1.Text += watch.ElapsedTicks + ": Page_SaveStateComplete<br/>";
    }
    protected void Page_Render(object sender, EventArgs e)
    {
        Response.Write(watch.ElapsedTicks + ": Page_Render<br/>");
        Label1.Text += watch.ElapsedTicks + ": Page_Render<br/>";
    }
 
    protected void Button1_Click(object sender, EventArgs e)
    {
        Response.Write(watch.ElapsedTicks + ": Button1_Click<br/>");
        Label1.Text += watch.ElapsedTicks + ": Button1_Click<br/>";
    }
}

MSDN: ASP.NET 页生命周期概述

posted @   客家岸田  阅读(310)  评论(0编辑  收藏  举报
编辑推荐:
· 如何打造一个高并发系统?
· .NET Core GC压缩(compact_phase)底层原理浅谈
· 现代计算机视觉入门之:什么是图片特征编码
· .NET 9 new features-C#13新的锁类型和语义
· Linux系统下SQL Server数据库镜像配置全流程详解
阅读排行:
· Sdcb Chats 技术博客:数据库 ID 选型的曲折之路 - 从 Guid 到自增 ID,再到
· Winform-耗时操作导致界面渲染滞后
· Phi小模型开发教程:C#使用本地模型Phi视觉模型分析图像,实现图片分类、搜索等功能
· 语音处理 开源项目 EchoSharp
· drools 规则引擎和 solon-flow 哪个好?solon-flow 简明教程
联系和建议: antield[at]126.com
点击右上角即可分享
微信分享提示