Advertisement
Guest User

Untitled

a guest
Aug 19th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. protected void Timer1_Tick(object sender, EventArgs e)
  2. {
  3. DateTime NeededByDateTime = (DateTime)ViewState["NeededByDateTime"];
  4. TimeSpan time1 = new TimeSpan();
  5. time1 = NeededByDateTime - DateTime.Now;
  6.  
  7. if ((time1.Hours <= 0) && (time1.Minutes <= 0) && (time1.Seconds <= 0))
  8. {
  9.  
  10. lblCountdownTicker.Text = "Time Expired!";
  11. }
  12. else
  13. {
  14.  
  15. string countDown = string.Format("{0} Days, {1} Hours, {2} Minutes, {3} Seconds until expiration.", time1.Days, time1.Hours, time1.Minutes, time1.Seconds);
  16.  
  17. string newCountDown = "<h4 style = 'color: blue' >" + countDown + "</ h4>";
  18.  
  19. lblCountdownTicker.Text = newCountDown.ToString();
  20. }
  21.  
  22. }
  23.  
  24. <asp:ScriptManager ID="ScriptManager1" runat="server" />
  25.  
  26. <asp:UpdatePanel ID="UpdatePanel1" Visible="true" runat="server" UpdateMode="Conditional" >
  27. <ContentTemplate>
  28.  
  29. <asp:Label ID="lblCountdownTicker" runat="server"></asp:Label>
  30. <asp:Label ID="Label1" runat="server" Text=""></asp:Label>
  31. </ContentTemplate>
  32. <Triggers>
  33. <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
  34. </Triggers>
  35. </asp:UpdatePanel>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement