Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3350618
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T01:48:31+00:00 2026-05-18T01:48:31+00:00

hii I want to insert a countdown timer in my project. right now i

  • 0

hii
I want to insert a countdown timer in my project. right now i am using the following code:

{

    DateTime dt = (DateTime)Session["end_t"];
    DateTime dt_curr = DateTime.Now;
    TimeSpan ts = dt - dt_curr;
    lblTimer.Text = ts.Hours.ToString() + ":" + ts.Minutes.ToString() + ":" + ts.Seconds.ToString();
    if (ts.Minutes == 0)
    {
        Timer1.Enabled = false;
        Response.Redirect("~/Online Exam/result2.aspx");
    }

the code works fine but when we move to some other page and then return back to main page the timer gets restarted.
How can i overcome with this? Please help

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T01:48:32+00:00Added an answer on May 18, 2026 at 1:48 am

    It looks like you’re resetting the end time on each page load, probably by doing something like:

    protected void Page_Load(object sender, EventArgs e)
    {
        DateTime start_time = DateTime.Now;
        DateTime end_time = start_time.AddMinutes(15);
        Session["end_t"] = end_time;
    }
    

    Instead, you should store the end time only if the timer is not already running:

    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["end_t"] == null) {
            DateTime start_time = DateTime.Now;
            DateTime end_time = start_time.AddMinutes(15);
            Session["end_t"] = end_time;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hii, I want to make my own snmp server and agent.with my own MIB
Hi I want to insert all escape characters in a column in MySQL. I
Hi I have a database with loads of columns and I want to insert
Hi I want to copy an xml file and insert in a specific element
Hi i want to write a game with a main game form and lot
Hi I want to have two tables each have an INT id column which
Hi I am trying to deploy an application using webstart. I have a requirement
Hi i have a store procedure, where i do a select query. I want
Hi I made a human computer interface to control mouse using fingers using C++
Hii.. How can I access abstract class methods in zend form? I have the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.