Last post Jul 09, 2015 09:53 PM by Krunal Parekh
Jul 07, 2015 09:12 PM|Khalid Osama|LINK
I have an update panel with a div (with runat="server") so I dynamically create and add buttons to it on a timer tick event.
The problem is that when a button is click, the is a postback but the button is gone and the event is not raised.
Here's my aspx page and my c# code behind. Nothing I write in the btn1_click actually occurs.
There's a continue to my question but in order to keep it simple, I would like to understand the above first.
I really need your help and i appreciate it, ty.
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
<asp:Timer ID="Timer1" runat="server" Interval="2000" ontick="Timer1_Tick">
<asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="server">
<asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
<div id="div1" runat="server"></div>
<div id="div2" runat="server">div2</div>
public partial class WebForm1 : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)
protected void Timer1_Tick(object sender, EventArgs e)
Button btn1 = new Button();
btn1.ID = "btn1";
btn1.Text = "click me";
btn1.Click += new EventHandler(btn1_Click);
void btn1_Click(object sender, EventArgs e)
div1.InnerHtml += "btn1 was clicked";
Jul 07, 2015 09:18 PM|mostafasydney|LINK
Welcome to this forum.
Please refer to this thread:
Curious about why the 2 threads are identical!
Hope this will help.
Jul 07, 2015 09:31 PM|Khalid Osama|LINK
First, thank you.
i saw that page .. but its doesnt solve my problem.
Jul 09, 2015 09:53 PM|Krunal Parekh|LINK
Hope this helps.