当前位置: 代码迷 >> ASP.NET >> .NET 首页登录 点击登录后,不跳转,该怎么处理
  详细解决方案

.NET 首页登录 点击登录后,不跳转,该怎么处理

热度:1640   发布时间:2013-02-25 00:00:00.0
.NET 首页登录 点击登录后,不跳转
在登陆页面的 ImageButton1的事件如下:但是点击时不跳转是什么原因???麻烦大家帮忙看看。。。谢谢!!
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
  {
  if (TextBox2.Text.ToString().Trim() == "" || TextBox1.Text.ToString().Trim() == "")
  {
  Response.Write("<script>javascript:alert('请输入完整');history.back();</script>");
  Response.End();
  }
  string sql;

  sql = "select * from allusers where username='" + TextBox2.Text.ToString().Trim() + "' and pwd='" + TextBox1.Text.ToString().Trim() + "'";

  DataSet result = new DataSet();
  result = new Class1().hsggetdata(sql);
  // result = new TestOnline.Class1().hsggetdata(sql);
  if (result != null)
  {
  if (result.Tables[0].Rows.Count > 0)
  {
  Session["username"] = TextBox2.Text.ToString().Trim();

  Session["role"] = result.Tables[0].Rows[0]["cx"].ToString().Trim();


  Response.Redirect("default.htm");
  }
  else
  {
  Response.Write("<script>javascript:alert('对不起,用户名或密码不正确!');</script>");
  }
  }
  else
  {
  Response.Write("<script>javascript:alert('对不起,系统错误,请不要越权操作!');</script>");
  }
  }

------解决方案--------------------------------------------------------
首先,先看看sql语句对不对?
其次,看看datatable中取到值了吗?
最后看看,default.htm路径对不对?
------解决方案--------------------------------------------------------
没看出来,设置断点调试吧
------解决方案--------------------------------------------------------
Response.Redirect("~/default.htm");
------解决方案--------------------------------------------------------
探讨

Response.Redirect("~/default.htm");

------解决方案--------------------------------------------------------
探讨
在登陆页面的 ImageButton1的事件如下:但是点击时不跳转是什么原因???麻烦大家帮忙看看。。。谢谢!!
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
if (TextBox2.Text.ToString().Trim() == "" || TextBox1……

------解决方案--------------------------------------------------------
不redirect就不会跳了
------解决方案--------------------------------------------------------
设置个断点看看,改成"/default.htm"试试。一般根目录下加上“/”
  相关解决方案