on the "AddHandler btnEditIdent, AddressOf MyButtonHandler" line, the
"btnEditIdent is underlined and the tooltips message I get when I hover over
the button is "'btnEditIdent is not a member of 'MyWeb.MyWebPage'" (where
MyWeb is the name of the application and MyWebPage is the name of the class
for that particular web page.
Yes, the table is inside the <form runat="server"> tag.
Point of clarification: The button is not defined on the web page itself
(in the MyWebPage.aspx file). Should it be? With anything special about it
since I don't intend to use that button but will be using multiple instances
of said button as determined by my code
Thanks for your time in looking at this.
Peter
"Lau Lei Cheong" <le****@yehoo.com.hk> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Seems the code is okay... so what is the error message?
Also make sure you're placing the control inside table within the <form
runat="server"> tag.
"Peter Vermilye" <pv*******@nospam.desotosystems.com>
¼¶¼g©ó¶l¥ó·s»D:O4**************@TK2MSFTNGP09.phx.g bl...
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