Hi Michael,
Thank you for posting in the community!
Based on my understanding, you have 2 web controls on the web form, 1 is a
normal button control, the other is an imagebutton. You want to use the
same event handler for these 2 buttons' click event.
=========================================
Actually, the Button's click event takes the normal EventHandler class,
while the ImageButton click event use the ImageClickEventHandler.
They take different EventArgs parameters. This is by the design of the C#
language. So you can not do like this.(I see you already understand this
point)
I think your 2 buttons(Button and ImageButton) may have the same click
handle logic, so you want to use the same event handler for them.
I think you can place the common click handle logic into a private method,
then use 2 different event handlers for each click event.
In both event handler, you can invoke this private method, then it will
behave the same as what you want.
Actually, for ImageButton's click event, .Net expose more feature for the
user to use, so it uses ImageClickEventHandler for its click event. This
event handler takes ImageClickEventArgs parameter, which has 2 more fields
"X" and "Y" to represent the coordinates where a user clicked on an
image-based ASP.NET server control.
That's why .Net expose 2 different event handlers for these 2 Buttons.
========================================
Please apply my suggestion above and let me know if it helps resolve your
problem.
Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.
Have a nice day!!
Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! -
www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.