我可以找出哪些控制事件会在ASP回发时触发吗? [英] Can I find out which control events will fire on an ASP postback?
问题描述
是否可以在 Page_Load
处理程序内部获取将要触发的控制事件的列表?
Is it possible to get a list of control events that are going to fire before they happen, say inside the Page_Load
handler?
例如,如果单击了一个按钮,我可以在调用 button_click
事件处理程序之前解决这个问题吗?
For example if a button was clicked can I figure this out before the button_click
event handler is called?
推荐答案
您已经选择了一个非常棘手的问题...其原因是事件可以通过多种方式触发.
You've picked a really tough question... the reason for this is that there are several ways that events will fire.
1)__EVENTTARGET(如上所述)2)如果您的按钮名称是MyButt,那么您将在查询字符串中看到"MyButt =.3)当每个控件(例如,一个TextBox)检查该请求以查看其在ViewState中的值是否不同于发布的值时,将触发"Text_Changed".
1) __EVENTTARGET (as mentioned above) 2) If the name of your button is MyButt, then you'll see "MyButt=" in the query string. 3) When each control (like, a TextBox for example) checks the request to see if it's value in the ViewState is different than posted, then a "Text_Changed" will fire.
但是,您可以使用#1和#2来检查几个地方.
But, you can use #1, and #2 to check a few places.
这篇关于我可以找出哪些控制事件会在ASP回发时触发吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!