I am writing a web application that builds buttons on the fly, then it ties the onclick event to a procedure. From the procedure how do I determine which button was clicked.
ex.
Dim btn(var) As Button
Dim i As Integer
For i = 0 To var
btn(i) = New Button()
btn(i).ID = "bttn" & i.ToString
AddHandler btn(i).Click, AddressOf myEventHandler
Next
Sub myEventHandler (ByVal sender As System.Object, ByVal e As System.EventArgs)
{if this button was pressed do this }
End Sub
Comments
Within your sub...
sender.Name represents the name of the button clicked
Hope this helps,
Chris
: I am writing a web application that builds buttons on the fly, then it ties the onclick event to a procedure. From the procedure how do I determine which button was clicked.
:
: ex.
:
: Dim btn(var) As Button
: Dim i As Integer
: For i = 0 To var
: btn(i) = New Button()
: btn(i).ID = "bttn" & i.ToString
: AddHandler btn(i).Click, AddressOf myEventHandler
:
: Next
:
:
: Sub myEventHandler (ByVal sender As System.Object, ByVal e As System.EventArgs)
:
: {if this button was pressed do this }
:
:
: End Sub
:
Thank you, that worked great!!
: Hi,
:
: Within your sub...
:
: sender.Name represents the name of the button clicked
:
: Hope this helps,
:
: Chris
:
: : I am writing a web application that builds buttons on the fly, then it ties the onclick event to a procedure. From the procedure how do I determine which button was clicked.
: :
: : ex.
: :
: : Dim btn(var) As Button
: : Dim i As Integer
: : For i = 0 To var
: : btn(i) = New Button()
: : btn(i).ID = "bttn" & i.ToString
: : AddHandler btn(i).Click, AddressOf myEventHandler
: :
: : Next
: :
: :
: : Sub myEventHandler (ByVal sender As System.Object, ByVal e As System.EventArgs)
: :
: : {if this button was pressed do this }
: :
: :
: : End Sub
: :
:
: