Issue with Dynamically created control Click_event
I have a ASP Button control 'B'. I want some linkbuttons to be created in the Click event of the 'B' button. And inturn i want some functions to be done in the click event of the Linkbuttons created.
But when i click the Linkbutton, it disappears during page_load event.
So how i can recreate the LinkButton in page_load event since i want the linkbutton to be created only when i click the 'B' button?Please help.
My code behind:
in .aspx page i have:
<asp:Button ID="search" runat="server" OnClick ="B_Click" Text="Click" />
protected void B_Click(object sender, EventArgs e)
LinkButton lnk = new LinkButton();
lnk.ID = "lnkB1";
lnk.Text = "lnkClick";
lnk.Click += new EventHandler(lnk_Click);
Page.EnableViewState = false;
protected void lnk_Click(object sender, EventArgs e)
LinkButton lnk = (LinkButton)sender;
lnk.Text = "Thanks for clicking me";