ASP.NET Timer控件实现倒计时功能,如何让计时结束自动交卷
protectedvoidTimer1_Tick(objectsender,EventArgse){inthour;intminute;intsecond;intexam...
protected void Timer1_Tick(object sender, EventArgs e)
{
int hour;
int minute;
int second;
int examTime = 20;
if (Session["examtime"] != null)
{
examTime = Convert.ToInt32(Session["examtime"]);
}
// 如果还有剩余时间,就显示剩余的分钟和秒数
if (examTime > 0)
{
examTime--;
Session["examtime"] = examTime;
hour = examTime / 3600;
minute = (examTime - hour * 3600) / 60;
second = examTime % 60;
lblTimer.Text = string.Format("{0:00}:{1:00}:{2:00}", hour, minute, second);
}
} 展开
{
int hour;
int minute;
int second;
int examTime = 20;
if (Session["examtime"] != null)
{
examTime = Convert.ToInt32(Session["examtime"]);
}
// 如果还有剩余时间,就显示剩余的分钟和秒数
if (examTime > 0)
{
examTime--;
Session["examtime"] = examTime;
hour = examTime / 3600;
minute = (examTime - hour * 3600) / 60;
second = examTime % 60;
lblTimer.Text = string.Format("{0:00}:{1:00}:{2:00}", hour, minute, second);
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询