.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");
[解决办法]