.net 做了一个登录页面,然后点击登录按钮后应该跳转的,可是一点击登录按钮就刷新了,而且不会跳转,我想设置登录按钮位置事件的断点,可是无论我在加载还是在登录按钮事件上,断点丝毫不起作用?不知道什么原因?好像在其他页面设置断点也不起作用,这到底是哪方面的原因呢?是vs2010有问题,IE浏览器有问题,还是代码有问题?有点懵,请高手帮帮忙!
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="login.aspx.cs" Inherits="login" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="lblUserName" runat="server" Text="用户名 "></asp:Label>
<asp:TextBox ID="txtUserName" runat="server"></asp:TextBox><br />
<asp:Label ID="lblPassword" runat="server" Text="密码 "></asp:Label>
<asp:TextBox ID="txtPassword" runat="server"></asp:TextBox><br />
<asp:Button ID="btnLogin" runat="server" Text="登录" onclick="btnLogin_Click" /><br />
<asp:Label ID="lblHelp" runat="server" Text=""></asp:Label>
</div>
</form>
</body>
</html>using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using log4net;
using System.Data.SqlClient;public partial class login : System.Web.UI.Page
{
//日志
private static ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnLogin_Click(object sender, EventArgs e)
{
string sql = "SELECT Pre where where Name='" + txtUserName.Text.Trim() + "' and Password='" + txtPassword.Text.Trim() + "'";
SqlConnection conn = new SqlConnection(Connection.userConnString);
try
{
conn.Open();
SqlCommand command = new SqlCommand(sql, conn);
string Pre = command.ExecuteScalar().ToString();
Session["Pre"] = Pre;
}
catch (Exception ex)
{
lblHelp.Text = "登录失败,请重新登录";
log.Error("登录异常:" + ex.Message);
}
finally
{
conn.Close();
} if (Session["Pre"] == "admin")
{
//进入主页
Response.Redirect("main.aspx");
}
else
{
Response.Redirect("login.aspx");
lblHelp.Text = "登录失败,请重新登录";
}
}
}
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="login.aspx.cs" Inherits="login" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="lblUserName" runat="server" Text="用户名 "></asp:Label>
<asp:TextBox ID="txtUserName" runat="server"></asp:TextBox><br />
<asp:Label ID="lblPassword" runat="server" Text="密码 "></asp:Label>
<asp:TextBox ID="txtPassword" runat="server"></asp:TextBox><br />
<asp:Button ID="btnLogin" runat="server" Text="登录" onclick="btnLogin_Click" /><br />
<asp:Label ID="lblHelp" runat="server" Text=""></asp:Label>
</div>
</form>
</body>
</html>using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using log4net;
using System.Data.SqlClient;public partial class login : System.Web.UI.Page
{
//日志
private static ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnLogin_Click(object sender, EventArgs e)
{
string sql = "SELECT Pre where where Name='" + txtUserName.Text.Trim() + "' and Password='" + txtPassword.Text.Trim() + "'";
SqlConnection conn = new SqlConnection(Connection.userConnString);
try
{
conn.Open();
SqlCommand command = new SqlCommand(sql, conn);
string Pre = command.ExecuteScalar().ToString();
Session["Pre"] = Pre;
}
catch (Exception ex)
{
lblHelp.Text = "登录失败,请重新登录";
log.Error("登录异常:" + ex.Message);
}
finally
{
conn.Close();
} if (Session["Pre"] == "admin")
{
//进入主页
Response.Redirect("main.aspx");
}
else
{
Response.Redirect("login.aspx");
lblHelp.Text = "登录失败,请重新登录";
}
}
}
string sql = "SELECT Pre where where Name='" + txtUserName.Text.Trim() + "' and Password='" + txtPassword.Text.Trim() + "'";
这一行 点按钮后 然后F11