Brandon

Brandon

  • NA
  • 4
  • 0

Help with VS/C# timer class. I need to force a page submit during a quiz...

Mar 9 2008 11:57 PM
I'm having a slight problem with timing out a user. The basics of it is that its a quiz application. The user has a set amount of time to answer the questions, once the time limit has expired, the page has to be submitted for evaluation whether the user is finished or not.

The problem is that on the timeout it doesnt recognize the radio buttons as actually being selected, and then it throws an unhandled exception error. And server.transfer() and response.redirect() fail as well. The page works fine if the actual submit button is clicked though. Can anyone tell me whats wrong with this page? This event fires every 2 minutes and the page breaks on it. Also MessageLine (a label to display feedback) doesnt show anything either.

private void Countdown_Tick(object sender, System.EventArgs e)
{
int TimeRemainning = int.Parse(Session["TimeRemainning"].ToString());
TimeRemainning--;
Session["TimeRemainning"] = TimeRemainning;
if (TimeRemainning <= 0)
{
Countdown.Stop();
//Server.Transfer("ModuleSelection.aspx", true);
//Response.Redirect("ModuleSelection.aspx");
//HttpContext.Current.Response.Redirect("FinalAssessment.aspx");
HttpContext.Current.Server.Transfer("FinalAssessment.aspx", true);
}
MessageLine.Text = DateTime.Now.ToString();
}

Oh and these are the errors that pop up for Server.Transfer, Response.Redirect and HttpContext respectively.

{"Error executing child request for ModuleSelection.aspx."}

{"Response is not available in this context."}

{"Object reference not set to an instance of an object."}