开发者

Asp.net is it possible to check page_load a click event is triggered?

开发者 https://www.devze.com 2022-12-09 07:45 出处:网络
When a button is clicked, I would lik开发者_如何学Pythone to check whether a button is clicked in my page_load. Is this possible? I am using asp.net 2.0 C#You can check the IsPostBack flag to see if i

When a button is clicked, I would lik开发者_如何学Pythone to check whether a button is clicked in my page_load. Is this possible? I am using asp.net 2.0 C#


You can check the IsPostBack flag to see if it was a postback rather than an initial load. This may be what you're after. Also, you can check the Request.Form["__EVENTTARGET"] from which you can obtain information about the control that raised the event and therefore find out if it was one of your buttons from there.


The button click event will fire after the page load event has. That being said, you can always check the http header to see what value is being pushed back through the request.form event. The button id will be in there if it has been fired.


I can think a work around by creating a hidden field and changing the value when a certain button is clicked and checking it value in Page_Load.

0

精彩评论

暂无评论...
验证码 换一张
取 消