I have ASPX web page which has a Button on it. Once user click this button, request is submitted to server and button click event handler is executed.
I have some logic that must reside on Page.Load, but this logic depends if request has been submitted by button click. Based on page life cycle event handlers executes after Page Load.
Question: How in Page load I can find out what event handlers are going to be executed after Page Load?
@akton’s answer is probably what you SHOULD do, but in case you want to go off the reservation and determine what is causing a postback early on in the lifecycle, you can interrogate the postback data to determine what was clicked. This will NOT give you what actual functions/handlers will be executed during event handling, however.
First, if something other than a
Button/ImageButtoncaused the postback, the ID of the control will be in__EVENTTARGET. If aButtoncaused the postback, there is something “cute” ASP.NET does: it ignores all other buttons so that only the clicked button shows up on the form. AnImageButtonis a little different, because it will send coordinates. A utility function you can include:All that being said, if you can refactor your control/page to delay execution, your code will be much cleaner/more robust if you use the paradigm suggested by @akton.