on the "AddHandler btnEditIdent, AddressOf MyButtonHandler " line, the
"btnEditIde nt is underlined and the tooltips message I get when I hover over
the button is "'btnEditId ent is not a member of 'MyWeb.MyWebPag e'" (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.c om.hk> wrote in message
news:%2******** ********@TK2MSF TNGP12.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*******@nosp am.desotosystem s.com>
¼¶¼g©ó¶l¥ó·s»D: O4************* *@TK2MSFTNGP09. phx.gbl...
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.W ebControls.Butt on
Protected WithEvents tblDynamic As System.Web.UI.W ebControls.Tabl e
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
.
.
.
btnEditIdent = new System.Web.UI.W ebControls.Butt on
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