Handling events

  • Thread starter Thread starter SOS
  • Start date Start date
S

SOS

Hi guys,
i need to create some of my controls dynamically.
for example i want to create a button on my web form with this code :

Dim btnMyButton As New Button
Me.Controls.Add(btnMyButton)

how can i handle the events of this button ?

Thanx
 
using the AddHandler Keyword.

AddHandler btnMyButton.Click, Addressof MyEventHandler

Where myEventHandler is the name of the function that you will create to
handle the event.

Just make sure that the function is declared using the following syntax
Private Sub myEventHandler (sender as object, e as System.EventArgs)

Regards,
Nauzad Kapadia [MVP]
 
Back
Top