asp.net用户名密码输入错误三次关闭网页
protectedvoidButton1_Click1(objectsender,EventArgse){if(TextBox4.Text!=Request.Cookie...
protected void Button1_Click1(object sender, EventArgs e)
{
if (TextBox4.Text != Request.Cookies["CheckCode"].Value.ToString())
{
Response.Write("<script>alert('请填入正确的验证码')</script>");
Response.Write("<script>history.go(-1)</script>");
Response.End();
}
else
{
string strSQL = "select * from 用户信息 where 用户名='" + TextBox1.Text + "' AND 密码='" + TextBox2.Text + "'";
if (DbManager.ExecuteQuery(strSQL).Rows.Count > 0)
{
Session["name"] = TextBox1.Text;
string username = null;
if (Session["name"] != null)
{
username = Session["name"].ToString();
}
Label1.Text = TextBox1.Text + "欢迎光临";
Panel1.Visible = false;
TextBox1.Visible = false;
TextBox2.Visible = false;
Button1.Visible = false;
HyperLink1.Visible = false;
Panel2.Visible = true;
}
else
{
int ErrorTimes = 0;
if (ErrorTimes ==2)
{
Response.Write("<script>alert('错误输入3次,即将关闭网页!')</script>");
Response.Write("<script>window.opener=null;window.close();</script>");
Response.End();
}
else
{
Response.Write("<script>alert('请输入正确的用户名和密码!')</script>");
Response.Write("<script>history.go(-1)</script>");
Response.End();
ErrorTimes = ErrorTimes + 1;
}
}
}
}
可以运行,但是错误三次后网页还是运行,没有关闭 展开
{
if (TextBox4.Text != Request.Cookies["CheckCode"].Value.ToString())
{
Response.Write("<script>alert('请填入正确的验证码')</script>");
Response.Write("<script>history.go(-1)</script>");
Response.End();
}
else
{
string strSQL = "select * from 用户信息 where 用户名='" + TextBox1.Text + "' AND 密码='" + TextBox2.Text + "'";
if (DbManager.ExecuteQuery(strSQL).Rows.Count > 0)
{
Session["name"] = TextBox1.Text;
string username = null;
if (Session["name"] != null)
{
username = Session["name"].ToString();
}
Label1.Text = TextBox1.Text + "欢迎光临";
Panel1.Visible = false;
TextBox1.Visible = false;
TextBox2.Visible = false;
Button1.Visible = false;
HyperLink1.Visible = false;
Panel2.Visible = true;
}
else
{
int ErrorTimes = 0;
if (ErrorTimes ==2)
{
Response.Write("<script>alert('错误输入3次,即将关闭网页!')</script>");
Response.Write("<script>window.opener=null;window.close();</script>");
Response.End();
}
else
{
Response.Write("<script>alert('请输入正确的用户名和密码!')</script>");
Response.Write("<script>history.go(-1)</script>");
Response.End();
ErrorTimes = ErrorTimes + 1;
}
}
}
}
可以运行,但是错误三次后网页还是运行,没有关闭 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询