我有一个代码和一个像这样的数组:
using System;
public partial class bug : System.Web.UI.Page
{
double[] Score = new double[10];
protected void Page_Load(object sender, EventArgs e)
{
load the form with questions from database (but show only one)
}
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
when this clicked, evaluate the answer from TextBox1 and write the score to Score[questionnumber].
}
protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
{
go to the question of the clicked Hyperlink's number.
}
}
所以,发生的事情是,我打开这个网站,我看到第一个问题,我输入我的答案并提交它,然后它返回我第一个问题的分数,然后我点击第二个问题的超链接,表单将我带到我的第二个问题问题,这里是问题发生了,我不知道为什么,但是数组(分数数组)在这里被重置,所以当我提交我的第二个问题的答案时,它把答案放到 Score[0] 而不是把它放到问题编号的索引。也许它因此再次重新初始化。那么,我应该怎么做才能不发生它被重置?请帮忙,我真的需要它。