Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protected void Timer1_Tick(object sender, EventArgs e)
- {
- DateTime NeededByDateTime = (DateTime)ViewState["NeededByDateTime"];
- TimeSpan time1 = new TimeSpan();
- time1 = NeededByDateTime - DateTime.Now;
- if ((time1.Hours <= 0) && (time1.Minutes <= 0) && (time1.Seconds <= 0))
- {
- lblCountdownTicker.Text = "Time Expired!";
- }
- else
- {
- string countDown = string.Format("{0} Days, {1} Hours, {2} Minutes, {3} Seconds until expiration.", time1.Days, time1.Hours, time1.Minutes, time1.Seconds);
- string newCountDown = "<h4 style = 'color: blue' >" + countDown + "</ h4>";
- lblCountdownTicker.Text = newCountDown.ToString();
- }
- }
- <asp:ScriptManager ID="ScriptManager1" runat="server" />
- <asp:UpdatePanel ID="UpdatePanel1" Visible="true" runat="server" UpdateMode="Conditional" >
- <ContentTemplate>
- <asp:Label ID="lblCountdownTicker" runat="server"></asp:Label>
- <asp:Label ID="Label1" runat="server" Text=""></asp:Label>
- </ContentTemplate>
- <Triggers>
- <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
- </Triggers>
- </asp:UpdatePanel>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement