Attaching Multiple OnClick Events to the same Function [C#]

Shaitan00

Junior Contributor
Joined
Aug 11, 2003
Messages
358
Location
Hell
Given a web form with an Image Button and Link Button, both, when clicked, will re-direct the user to the main.aspx web form.

To achieve this goal I wanted to have both the Image Button and Link Button using the same function [OnClick = “Enter_Click” in html] which I created as “public void Enter_Click(object sender, System.EventArgs e)” which generated the following error, “Method 'TEST.WebForm1.Enter_Click(object, System.EventArgs)' does not match delegate 'void System.Web.UI.ImageClickEventHandler(object, System.Web.UI.ImageClickEventArgs)'” for the image button.

However if I use the one provided above it fails for my link button instead with a similar error except requested that I use “System.EventArgs e”, is there no way to do this in one function or must I write 2 separate ones, one for the Image Button and one for the Link Button (with the only difference being the Event Argument passed in)?
 
Not 100% sure what you mean, isn't that what I am currently trying to do?
Can you provide an example?
 
private function myfunction()

'do your stuff here
end function

call this function in the eventhandlers of your imagebutton and linkbutton
 
Back
Top