如何实现登陆界面的用户名文本框,密码文本框与后台相联并且实现验证 同题目!谢谢大家在线等 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 建议你看一下asp.net验证控件,很简单的。特别是比较验证控件:CompareValidator 这是一篇关于验证控件的文章:http://www.chinabs.net/aspnet/default.asp?infoid=75 查找有无该用户然后进行密码判断最后进行跳转工作最好不是赋予一个SESSION,然后再在每个页面进行判断一下 给你一个做参考 private void ButtonLogin_Click(object sender, System.EventArgs e) { if((this.TextBoxUserCode.Text=="")||(this.TextBoxUserPassword.Text=="")) Page.RegisterStartupScript("check", "<script>alert('请正确输入用户和密码!');</script>"); else { string strLogin = "select count(UserCode) from TS_User where UserCode='"+this.TextBoxUserCode.Text.Trim()+"' and Password='"+ this.TextBoxUserPassword.Text.Trim() + "'"; this.sqlDataAdapter1.SelectCommand.CommandText =strLogin; this.sqlDataAdapter1.SelectCommand.Connection.Close(); this.sqlDataAdapter1.SelectCommand.Connection.Open(); int num = (int)this.sqlDataAdapter1.SelectCommand.ExecuteScalar(); if (num>0) { this.Session.Clear(); this.Session["UserCode"] = TextBoxUserCode; FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(this.Session["UserCode"].ToString(), true, 60); string EncTicket = FormsAuthentication.Encrypt(ticket); Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName, EncTicket)); Response.Redirect("Default.aspx",false); } else Page.RegisterStartupScript("check", "<script>alert('用户或者密码错误!');</script>"); } } 上面参考的FormsAuthenticationTicket这个是什么东东? AsyncFileUpload同一页面有六个以上后就出现“拒绝访问” ASP.net中视图显示的出来再firefox中却出现问题。。。? Windows CE 5.0怎样才能支持Ajax? 怎么把 静态网站改成动态网站? web程序如何备份 C# 如何作论坛,有没能好思路 请教一段脚本的firefox格式 无法打开asp.net web application? 还是数据库备份和恢复的问题,100分 为什么更新不了数据!!! 想知道怎么把asp.net编译好的.dll组件 注册到系统 在asp中来访问??????????????? 求助datagrid编辑、更新、取消
http://www.chinabs.net/aspnet/default.asp?infoid=75
最好不是赋予一个SESSION,然后再在每个页面进行判断一下
{
if((this.TextBoxUserCode.Text=="")||(this.TextBoxUserPassword.Text==""))
Page.RegisterStartupScript("check", "<script>alert('请正确输入用户和密码!');</script>");
else
{
string strLogin = "select count(UserCode) from TS_User where UserCode='"+this.TextBoxUserCode.Text.Trim()+"' and Password='"+ this.TextBoxUserPassword.Text.Trim() + "'";
this.sqlDataAdapter1.SelectCommand.CommandText =strLogin;
this.sqlDataAdapter1.SelectCommand.Connection.Close();
this.sqlDataAdapter1.SelectCommand.Connection.Open();
int num = (int)this.sqlDataAdapter1.SelectCommand.ExecuteScalar();
if (num>0)
{
this.Session.Clear();
this.Session["UserCode"] = TextBoxUserCode;
FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(this.Session["UserCode"].ToString(), true, 60);
string EncTicket = FormsAuthentication.Encrypt(ticket);
Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName, EncTicket));
Response.Redirect("Default.aspx",false);
}
else
Page.RegisterStartupScript("check", "<script>alert('用户或者密码错误!');</script>");
}
}