Answered by:
timer and updatepanel

Question
-
User669521406 posted
i have created a duration label that take the end date - the actual date
but when i have insert a new updatepanel, it stop to work by?
Friday, February 14, 2014 6:45 AM
Answers
-
User2103319870 posted
Hi,
Are you trying to create a count down timer. if so you can try with the below code
HTML Mark up:
<asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:Timer ID="Timer2" runat="server"> </asp:Timer> <asp:Label ID="Label1" runat="server" Text="60" style="display:none;"></asp:Label> <asp:Button ID="Button1" runat="server" Text="Button" /> </ContentTemplate> </asp:UpdatePanel>
You can increase the timer interval by setting the text value of label above
C#:
protected void Page_Load(object sender, EventArgs e) { Timer2.Enabled = true; Timer2.Interval = 1000; Timer2.Tick += new EventHandler<EventArgs>(Timer1_Tick); } void Timer1_Tick(object sender, EventArgs e) { int i = (Convert.ToInt16(Label1.Text)); i = i - 1; Label1.Text = i.ToString(); if (i < 0) { //Time up Send your mail here } }
You can check the below link
Alternatively you can also try implementing the counter using Jquery
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Friday, February 14, 2014 6:58 PM
All replies
-
User336673788 posted
can you post your html and code?
Friday, February 14, 2014 6:49 PM -
User2103319870 posted
Hi,
Are you trying to create a count down timer. if so you can try with the below code
HTML Mark up:
<asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:Timer ID="Timer2" runat="server"> </asp:Timer> <asp:Label ID="Label1" runat="server" Text="60" style="display:none;"></asp:Label> <asp:Button ID="Button1" runat="server" Text="Button" /> </ContentTemplate> </asp:UpdatePanel>
You can increase the timer interval by setting the text value of label above
C#:
protected void Page_Load(object sender, EventArgs e) { Timer2.Enabled = true; Timer2.Interval = 1000; Timer2.Tick += new EventHandler<EventArgs>(Timer1_Tick); } void Timer1_Tick(object sender, EventArgs e) { int i = (Convert.ToInt16(Label1.Text)); i = i - 1; Label1.Text = i.ToString(); if (i < 0) { //Time up Send your mail here } }
You can check the below link
Alternatively you can also try implementing the counter using Jquery
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Friday, February 14, 2014 6:58 PM