P
Peter Vermilye
How can I dynamically create buttons and wire them to an event handler? I
have seen how I can add buttons to an event handler that are pre-created as
part of the codebehind using AddHandler, but I can't use AddHandler with a
button that is created locally, nor can I seem to create multiple button
objects and add them to the page using a button object that exists outside
the procedure I am using.... thus:
Protected WithEvents btnEditIdent As System.Web.UI.WebControls.Button
Protected WithEvents tblDynamic As System.Web.UI.WebControls.Table
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
..
..
..
btnEditIdent = new System.Web.UI.WebControls.Button
btnEditIdent.id="btn" & strSomeUniqueID
dim tc as TableCell
AddHandler btnEditIdent, AddressOf MyButtonHandler
tc.Controls.Add(btnEditIdent)
..
..
..
End Sub
Seems like the above should work. But it generates an error.
Any ideas?
Thanks
Peter R. Vermilye
have seen how I can add buttons to an event handler that are pre-created as
part of the codebehind using AddHandler, but I can't use AddHandler with a
button that is created locally, nor can I seem to create multiple button
objects and add them to the page using a button object that exists outside
the procedure I am using.... thus:
Protected WithEvents btnEditIdent As System.Web.UI.WebControls.Button
Protected WithEvents tblDynamic As System.Web.UI.WebControls.Table
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
..
..
..
btnEditIdent = new System.Web.UI.WebControls.Button
btnEditIdent.id="btn" & strSomeUniqueID
dim tc as TableCell
AddHandler btnEditIdent, AddressOf MyButtonHandler
tc.Controls.Add(btnEditIdent)
..
..
..
End Sub
Seems like the above should work. But it generates an error.
Any ideas?
Thanks
Peter R. Vermilye