• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 246
  • Last Modified:

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"
0
EchoBinary
Asked:
EchoBinary
1 Solution
 
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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now