Determine which button inside the custom control dispatched the event
I have a custom control with multiple buttons.
Q page_load
, I want to run a method if a specific button has not been clicked.
When I check the sender for page_load
inside the custom control, I just get the name of the custom control, not the button itself.
Is there a way to determine which button was clicked on page_load
? Otherwise, I will have to come up with a hacky method to solve the problem.
source to share
I think you can check Request.Form ("__EVENTTARGET")
which should contain ClientID
your control.
This refers to the hidden field value used by the ASP.NET event handling framework to track what the user has clicked. When the user triggers the feedback, some JavaScript on the page sets this hidden field to the ClientID
control you clicked before submitting the form.
source to share
Are you sure you are working with the page model correctly? Page Load event (to create a server side object model), then your control will handle the button click event associated with the control.
Page loading can occur for any number of feedback reasons, with the exception of button clicks in a custom control.
How about buttons in other controls on the page?
There are sometimes good reasons for doing this, but I am also worried that you are just hacking into an ASP.NET page page.
source to share