探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 页生命周期概述
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 如何打造一个高并发系统?
· .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 简明教程