手写登录

namespace X
{
     public class Login:System.Web.UI.Page
{
    protected string PreUserName={get;set;}
protected string Js={get;set;}
protected void Load_Page(object sender,EventAges e)
{
    if(!IsPostBack)
{
    PreUserName=Request.Cookies["txtusername"]==null?string.Empty:Request.Cookies["txtusername"].value;
 
}
else
{
    PreUserName=Request["txtLoginName"];
}
 
}
protected void btnLoginClick(object sender,ImageButtonEventAges e)
{
    string sendCode=Session["ValidateCode"]==null?String.Empty:Session["ValidateCode"].ToString();
    string reviceCode=Request["txtCode"];
if(!sendCode.Equals(reviceCode))
{
   Js="<script>alert('验证码不正确')</script>";
return ;
}
string struserName=Request["txtLoginName"];
string strPwd=Request["txtPwd"];
BLL.CZBK_user Infouserservice=new CZBK_user();
Model.CZBK_user user=Infouserservice.getModelList(userName,Password);
    if(user==null)
{
    Js="<script>alert('用户名和密码不正确')</script>";
return;
}
Session["txtLoginName"]=user;
string name=Request["txtLogin"];
if(!string.IsNullOrEmpty(name))
{
    Response.Cookies["struserName"]=name;
Response.Cookies["struserName"].Expirse=DateTime.Now.AddDays(7);
}
Response.Redirct("AdminIndex.aspx");
}
}
}
posted @ 2013-05-09 07:09  nieyulin  阅读(157)  评论(0编辑  收藏  举报