根据条件绕过页面

时间:2011-06-27 19:27:11

标签: c# asp.net session

这是我的加载会话和保存会话值函数。如何选中保留所选值并使用它“跳过”某个页面?谢谢!

 protected override void LoadSessionValues()
    {
       if (Session["ddlClassification"] != null)
        {
            ddlClassification.SelectedValue = (String)Session["ddlClassification"];
        }
    }

  protected override void SaveSessionValues()
    {
        Session["ddlClassification"] = ddlClassification.SelectedValue;
    }

1 个答案:

答案 0 :(得分:5)

if (Session["ddlClassification"].ToString() == "valueToCheckFor")
{
Response.Redirect("page1.aspx", false);
}
else
{
Response.Redirect("page2.aspx", false);
}

根据以下评论更新

在page1.aspx

protected void Page_Load(object sender, EventArgs e)
{
    if (Session["ddlClassification"].ToString() == "valueToCheckFor" || Session["ddlClassification"] == null)
    {
    Response.Redirect("someOtherPage.aspx", false);
    }
}