Author: merrsh1 | Posted on: 9/21/2009 7:02:41 AM | Views : 495

If dynamic controls must be added within page_load in order for their events to be interceptable what happens if the controls themselves cannot be created until after this ? i.e the controls to be displayed are created by an event...
For example i have a button.  The buttons onclick is used to decide on the creation of another button, how do i add an event to the created button? 
The following does not work...
<asp:Button ID="btn1" runat="server" Text="Button" onclick="b1_Click" /> <asp:PlaceHolder ID="ph1" runat="server"> </asp:PlaceHolder> <asp:Literal ID="ltlOutput" runat="server"></asp:Literal> protected void b1_Click(object sender, EventArgs e) { ltlOutput.Text += " B1 Clicked "; Button b2 = new Button(); b2.ID = "b2"; b2.Click += new ...

Go to the complete details ...