如何在页面加载时增加要处理的步长值?例如,在下面的代码中,由于 ASP.NET 页面生命周期,viewstate 变量直到 Page_Load 之后才会递增。
protected void Page_Load(object sender, EventArgs e)
{
switch ((int)ViewState["step"])
{
//do something different for each step
}
}
protected void btnIncrementStep_Click(object sender, EventArgs e)
{
//when the button is clicked, this does not fire
//until after page_load finishes
ViewState["step"] = (int)ViewState["step"] + 1;
}