为什么index不能减为0
public partial class _Default : System.Web.UI.Page{
protected void Page_Load(object sender, EventArgs e)
{
}
/// <summary>
/// 定义在线考试总时间变量index,
/// 并设置读写属性
/// </summary>
private int index
{
get
{
object o = ViewState["index "];
return (o == null) ? 600 : (int)o;
}
set
{
ViewState["index "] = value;
}
}
protected void Timer1_Tick(object sender, EventArgs e)
{
this.index--;
if (this.index == 0) //考试时间到了
{
this.Timer1.Enabled = false;//设置Timer控件不可见
//时间到时,此处可编写自动提交试卷的方法
}
else
{
//显示考试剩余时间
this.lbTime.Text = this.index / 60 + "分" + this.index % 60 + "秒将停止考试,请及时“提交”试卷,否则试卷作费成绩无效!";
}
}
}
--------------------编程问答-------------------- this.index--;
=>
this.index = this.index - 1;
--------------------编程问答-------------------- return (o == null) ? 600 : (int)o;
=>
if (o == null) ViewState.Add("index ", 600);
return (int)ViewState["index "]; --------------------编程问答-------------------- this.Timer1.Enabled = false;//设置Timer控件不可见
当index ==0时,时间就停止了
晕,注释都写错了
至于为什么停止
谁写的问谁去
补充:.NET技术 , ASP.NET