Dynamic ASP.NET button control

T

Todd Acheson

Attention all Guru's,
Let's say I create a control at runtime similar to this:

'this is one button within a loop that creates many buttons

Dim ctl as New System.Web.UI.WebControls.Button
ctl.ID = strID 'strID is dynamic, a field from the database
ctl.Width = System.Web.UI.WebControls.Unit.Pixel(100)
ctl.Text = strButtonText ' strButtonText is dynamic, a field from the
database
plcPlaceHolder1.Controls.Add(ctl) ' plcPlaceHolder1 is a <asp:placeholder>
sandwiched in the web page's HTMLForm

When the user clicks this dynamically added button, what is the best way to
capture the event and execute some code in the codebehind file?
I can find out what button was clicked with the Request.Form object, but is
this the most effecient way to find out, and if so, what's the best way to
execute code for it? Will late binding play any part?

thanks for your time,

Todd Acheson
 

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

Members online

No members online now.

Forum statistics

Threads
474,099
Messages
2,570,626
Members
47,237
Latest member
David123

Latest Threads

Top