public partial class loginok : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
       Label1.Text = Session["teauser"].ToString();
       Label2.Text = Session["pos"].ToString();
    }
    protected void LinkButton1_Click(object sender, EventArgs e)
    {
        if (Label2.Text.ToString().Equals("管理员"))
        {
            Response.Redirect("admin.aspx");        }
        if (Label2.Text.ToString().Equals("教师"))
        {
            Response.Redirect("stuloginok.aspx");        }
        
    }
}不知道为什么页面跳转不了

解决方案 »

  1.   

    if(Session["teauser"]!=null&& Session["pos"]!=null){Label1.Text = Session["teauser"].ToString();
      Label2.Text = Session["pos"].ToString();
    }
    if("管理员".Equals(Label2.Text))
      

  2.   

    Session都有值没有??还有跳转的页面在同一个目录下嘛??检查一下,然后试试下面这样写法
    public partial class loginok : System.Web.UI.Page
    {
      protected void Page_Load(object sender, EventArgs e)
      {
          if(!IsPostBack)
          {
              Label1.Text = Session["teauser"].ToString();
              Label2.Text = Session["pos"].ToString();
          }
      }
     
      protected void LinkButton1_Click(object sender, EventArgs e)
      {
          if (Session["pos"].ToString().Trim().Equals("管理员"))
          {
                Response.Redirect("admin.aspx");
          }
          if (Session["pos"].ToString().Trim().Equals("教师"))
          {
                Response.Redirect("stuloginok.aspx");
          }
       }
    }
      

  3.   

    label1  ,label2   能取到session值么
      

  4.   

    if为false了吧。
    设置断点,Watch下Session中的内容,很容易解决的。
      

  5.   

     url 加上 AppathResponse.Redirect(Appath+"/stuloginok.aspx");
    虚拟 目录 造成
      

  6.   

    Label2.Text提交后取不到值的请用TextBox.Text