Asp.net can check page_load if click event triggered?

When a button is clicked, I would like to check if the button is clicked in my page_load. Is it possible? I am using asp.net 2.0 C #

+2


source to share


3 answers


You can check the flag IsPostBack

to make sure it was a postback and not a bootstrap. This might be what you need. Alternatively, you can check Request.Form["__EVENTTARGET"]

from which you can get information about the control that raised the event, and hence find out if it was one of your buttons.



+5


source


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



+1


source


I can think of this by creating a hidden field and changing the value when a specific button is clicked and checking its value in Page_Load.

0


source







All Articles