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]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top