日期:2014-05-17  浏览次数:20377 次

登陆页面跳转问题
protected void Button1_Click(object sender, EventArgs e)
  {
  SqlConnection con = DB.createDB();
  SqlCommand cmd = new SqlCommand();
  cmd.Connection = con;
  con.Open();//打开数据库连接
  cmd.CommandText = "select count(*) from tb_Users where UserName='"+this.txtUsers.Text+ "'and UserPwd='"+this.txtPassword.Text+"'";
  int a = Convert.ToInt32(cmd.ExecuteScalar());
  if (a > 0)
  {
   
   
  Response.Redirect("~Default.aspx");//为什么跳转不到我想要的页面啊???ie直接卡住

///////

///////
Response.Write("<script>alert('恭喜您登录成功!');location='javascript:history.go(-1)'</script>");
  Session["UserName"] = txtUsers.Text;
  Session["UserPwd"] = txtPassword.Text;
  txtUsers.Text="";
  txtPassword.Text = "";/////////而这个可也但是不是我想要的结果。我想的是跳转到我想要的页面,请大侠指点一下。。






  }
  else
  {
  Response.Write("<script>alert('很遗憾,登陆失败!');location='javascript:history.go(-1)'</script>");

  }
  con.Close();

  }
}

------解决方案--------------------
Response.Redirect("~/Default.aspx");
------解决方案--------------------
Response.Write("<script>alert('恭喜您登录成功!');location.href='/你要的页面.aspx'</script>");