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

  • SEARCH
  • Home
  • 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 3361086
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T03:06:37+00:00 2026-05-18T03:06:37+00:00

I am creating timed online test in C# asp.net. I have created it using

  • 0

I am creating timed online test in C# asp.net. I have created it using the local machine time. But in the case of Database disconnection or system hang, The countdown timer must start from the time at which the machine has hanged or unexpected database disconnectivity. For example the user is answering the Questions for 10 mins and unexpectedly system hanged. After recovery the countdown must start from 10 mins. Can anyone please help me with coding in C#?

I have used the following code, But its not useful in the above scenario.

int totalTime = (Convert.ToInt32(ViewState["totaltime"])) * 60;

DateTime startTime = (DateTime)ViewState["startTime"];
TimeSpan elaspedTime = DateTime.Now.Subtract(startTime);
Literal1.Text = elaspedTime.Hours.ToString() + "h" + ":" + elaspedTime.Minutes.ToString() + 
    "m" + ":" + elaspedTime.Seconds.ToString() + "s";

int finish = Convert.ToInt32(elaspedTime.TotalSeconds);

int remaingsec = (totalTime - finish);
TimeSpan remainingtime = TimeSpan.FromSeconds(remaingsec);
string answer = string.Format("{0:D2}h:{1:D2}m:{2:D2}s",
                    remainingtime.Hours,
                    remainingtime.Minutes,
                    remainingtime.Seconds,
                    remainingtime.Milliseconds);

LIteral2.Text =  answer;
if (totalTime == finish)
{
     lnkFinish_Click(sender, e);
     Response.Redirect(@"~/Error.aspx");
}
  • 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-18T03:06:38+00:00Added an answer on May 18, 2026 at 3:06 am

    My opinion is to use javascript for the countdown (embedded as well) and to pass your DB data with json, when DB cause disconnection you pass some data to javascript and with a control you proced to the countdown.

    Download the following javascript file and put into your web application directory:
    http://scripts.hashemian.com/js/countdown.js

    And than use something like this:

    <script type="text/javascript">
            TargetDate = "12/25/207 12:01 AM";
            BackColor = "red";
            ForeColor = "white";
            CountActive = true;
            CountStepper = -1;
            LeadingZero = true;
            DisplayFormat = "%%D%% Days, %%H%% Hours, %%M%% Minutes, %%S%% Seconds.";
            FinishMessage = "It is here!";
        </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating a large table dynamically using Javascript. I have realised the time
I have tried creating an install file but it never includes the database in
We are creating a Real-Time Process in VxWorks 6.x, and we would like to
I'm creating a jquery time entry in an onready() handler and hiding it in
On my app i am creating a real time trace (not sure how yet
I'm tired of opening Dia and creating a database diagram at the beginning of
I'm creating an application which lets you define events with a time frame. I
When loading a page for the first time (!IsPostback), I am creating a button
Has anyone tried creating end user (potentially online, potentially to be printed) help/documentation out
I'm making an online tile based game and I have just finished scripting 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.