帮看一下哦。。谢谢各位

No_Why_No_What 2012-05-30 09:41:48
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("server=localhost;Initial Catalog=luntan;Integrated Security=SSPI;uid=;pwd=");
try
{
con.Open();
}
catch (Exception ex)
{
throw ex;

}
string strcom;
strcom = "select count(*) from USERS where USERNAME='" + TextBox1.Text + "'and USERPWD='" + TextBox2.Text + "'";
SqlCommand com = new SqlCommand(strcom, con);
int a=Convert.ToInt32(com.ExecuteScalar());
if (a > 0)
{
Response.Write("<script>alert('恭喜您登录成功!');location='javascript:history.go(-1)'</script>");
Session["UserName"] = this.TextBox1.Text;
Session["UserPwd"] = this.TextBox2.Text;
this.Literal1.Text = Session["UserName"] .ToString()+ " " + "登录成功";
this.TextBox1.Text = "";//填写用户名的textbox
this.TextBox2.Text = "";//填写密码的textbox[/color]

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

}
con.Close();

}
登陆以后不能清空用户名和密码啊?这事什么原因啊?我是这样清空的
this.TextBox1.Text = "";//填写用户名的textbox
this.TextBox2.Text = "";//填写密码的textbox
还有this.Literal1.Text = Session["UserName"] .ToString()+ " " + "登录成功"; 这一句也不能显示
原来是可以清空的,因为是一边看书一边试,不知道什么时候他就清空不了了,不知道是不是自己该了什么东西!
...全文
73 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
No_Why_No_What 2012-05-31
  • 打赏
  • 举报
回复
能行了,能解释一下嘛?谢谢 给分了
人生无悔 2012-05-31
  • 打赏
  • 举报
回复

//把location...去掉
Response.Write("<script>alert('恭喜您登录成功!');'</script>");

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧