Hi,
you can just wire event handlers in code.
For example for the Image:
img.Load += new EventHandler(<handler_method_name_here>);
which sets up a handler for the Load event of the Image control. Just
specify the method where I've put the < and > stuff.
--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
http://blogs.aspadvice.com/joteke
"Mike" <no****@nospam.com> wrote in message
news:ut**************@TK2MSFTNGP12.phx.gbl...
Hi,
I am adding controls dynamically in a WebForm and would like to handle some
of their events. Here is the code to set up the dynamic controls:
System.Web.UI.WebControls.TableRow row = new TableRow();
System.Web.UI.WebControls.TableCell cell = new TableCell();
System.Web.UI.WebControls.HyperLink btn = new HyperLink();
System.Web.UI.WebControls.Image img = new System.Web.UI.WebControls.Image();
if (trk.Editable==true) {
btn.Text = " " + "Edit";
btn.Target = "WebForm1.aspx";
img.ImageUrl = "Images/img_sec/edit_pencil.gif";
cell.Height = 5;
cell.Controls.Add(img);
cell.Controls.Add(btn);
row.Cells.Add(cell);
m_Table.Rows.Add(row);
} else {
btn.Visible = false;
img.Visible = false;
}
Any idea on how to do it?
Thanks a lot.
Mike