|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
How to identify object that raised event
Hi,
I know you can trigger one event by multiple objects like: Code:
Private Sub Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click, Button2.Click, Button3.Click 'etc, etc
End Sub
My question is how can I identify which button triggered this event? Because I would expect something like "sender.name" But the only "useful" property is sender.ToString But if you check that string I get something like: Code:
System.Windows.Forms.Button, Text: Test button In the string I cannot find the object's ID. In case of a button you could filter out the "Text" part in this string, but it won't work if you have an input field. So..., how do I know which object triggered the event? Thanks in advance. |
|
#2
|
||||
|
||||
|
Hi,
Try something like this: Code:
Private Sub Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Dim ID As String ID = CType(Sender, Button).UniqueID 'etc.... End Sub |
|
#3
|
||||
|
||||
|
Thank you for your help.
I already got a similar solution: Code:
Dim triggerObj as string Dim btn as Button btn = DirectCast(sender, button) triggerObj = btn.name ... |
|
#4
|
||||
|
||||
|
yeah, the duplicate thread can be found here:
http://forums.aspfree.com/showthread.php?p=459437 --thread closed, thumbs down. |
| Viewing: ASP Free Forums > Programming > Visual Basic Programming > How to identify object that raised event |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|