Dynamic ASP.NET button control

  • Thread starter Thread starter Todd Acheson
  • Start date Start date
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
 
Back
Top