Asp.net Add Dynamic AJax timer to webform ....

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hey.. i want to add timers dymically by button click event of webforms...
I have 1 textbox and 1 button in webform..
ANd i have 1 updatepanel.. In which i add LABEL..
Here is my code..

protected void Button1_Click(object sender, EventArgs e)<br/>
{<br/>
<br/>
Timer timer1 = new Timer();<br/>
timer1.Interval = int.Parse( TextBox1.Text);<br/>
timer1.ID = textbox2.Text;<br/>
timer1.Enabled = true;<br/>
}<br/>
<br/>
public void Timer1_Tick(object sender, EventArgs e)<br/>
{<br/>
Timer timer = sender as Timer;<br/>
<br/>
timer.Enabled = false;<br/>
<br/>
<br/>
Label1.Text = timer.ID +" finished";<br/>
}<br/>
}

A <asp:ScriptManager ID="ScriptManager1" runat="server <br/>
</asp:ScriptManager><br/>
<br/>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Always <br/>
<ContentTemplate><br/>
<asp:Label ID="Label1" runat="server" Text="Label </asp:Label><br/>

<br/>
</ContentTemplate><br/>
</asp:UpdatePanel><br/>
<br />

View the full article
 
Back
Top