doramail05
asked on
Timer countdown with ASP.NET AJAX
i try to develop a countdown timer (not a bomb) to open another form and close the existing one
code below i found from article :
http://stackoverflow.com/questions/109064/countdown-timer-on-asp-net-page
the count down timer has to be 1:30:60
code below i found from article :
http://stackoverflow.com/questions/109064/countdown-timer-on-asp-net-page
the count down timer has to be 1:30:60
ajaxtimer.aspx
--------------
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Label ID="Label2" runat="server">30</asp:Label>
<asp:Label ID="Label1" runat="server">5</asp:Label>
<asp:Timer ID="Timer1" runat="server" Interval="1000"
ontick="Timer1_Tick">
</asp:Timer>
</ContentTemplate>
</asp:UpdatePanel>
ajaxtimer.aspx.cs
-----------------
protected void Timer1_Tick(object sender, EventArgs e)
{
int seconds = int.Parse(Label1.Text);
int minutes = int.Parse(Label2.Text);
int counter = 60;
// while (counter > 0)
if (seconds > 0)
{
Label1.Text = (seconds - 1).ToString();
}
else if (seconds == 0)
{
counter -= 1;
Label2.Text = (minutes - 1).ToString();
}
else
{
Timer1.Enabled = false;
}
}
So we guess what the problem with this is?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.