BrianFord
asked on
Get name of 'sender' in vb (asp) click event
I have an ASPX web page with VB code behind, there are 2 asp buttons in the page both being handled by the same event handler, which is...
How can I get the name of which of the two buttons was clicked? I have tried the following different methods but I always get the same error 'System.InvalidCastExcepti on'
Dim buttonClicked As Button = sender
or
Dim buttonClicked As Button = CType(sender, Button)
or
Dim buttonClicked As Button = DirectCast(sender, Button)
much Googling tells me either of these should work, but none of them do,
what am I missing?
Protected Sub cmdPrint_Click(sender As Object, e As EventArgs) Handles cmdPrint.Click, cmdReprint.Click
How can I get the name of which of the two buttons was clicked? I have tried the following different methods but I always get the same error 'System.InvalidCastExcepti
Dim buttonClicked As Button = sender
or
Dim buttonClicked As Button = CType(sender, Button)
or
Dim buttonClicked As Button = DirectCast(sender, Button)
much Googling tells me either of these should work, but none of them do,
what am I missing?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
lol no problem :)
ASKER
thanks for your response anyway :-)