If you want to add an eventhandler to like an array of controls that you dynamically add to the page, here is one way to do this:
Have Fun!Code:Protected WithEvents btn As System.Web.UI.WebControls.Button Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Put user code to initialize the page here Dim i As Integer For i = 0 To 3 btn = New System.Web.UI.WebControls.Button btn.Text = "blabla" btn.ID = i AddHandler btn.Click, AddressOf btn_Click Me.Controls.Add(btn) Next btn = Nothing End Sub Private Sub btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Label1.Text = sender.id End Sub




Reply With Quote