One Sub, Multiple event Handlers

Heres what I have:

Sub ItemsGet(Optional ByVal sender As Object = Nothing, Optional ByVal e As EventArgs = Nothing) Handles search_button.Click, cmdPrev.Click, cmdPrev.Click
..
code
...

=========================================================================
Is this even possible? If so, am I doing it right?
And - further  - if it is possible, how can I retrieve exactly which button was pressed.
I tried Response.Write(sender.ToString) but that wasnt useful, it just printed "System...Button"
EchoBinaryAsked:
Who is Participating?
 
marchianoCommented:
convert the sender object to button, e.g:


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click, Button2.Click, Button3.Click
      Label1.Text = CType(sender, Button).Text
End Sub

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.