当页面加载时,如何递增步骤值进行处理?例如,在以下代码中,由于ASP.NET页面生命周期,视图状态变量直到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;
}