类库中这么写的方法
public void SavaPwd(bool SavaPwdChk, string UserNameTxt, string PwdTxt)
{
if (SavaPwdChk == true)
{
HttpContext.Current.Response.Cookies["UserName"].Value = UserNameTxt;
HttpContext.Current.Response.Cookies["PwdTxt"].Value = PwdTxt;
HttpContext.Current.Response.Cookies["UserName"].Expires = DateTime.MaxValue;
HttpContext.Current.Response.Cookies["PwdTxt"].Expires = DateTime.MaxValue;
}
else
{
HttpContext.Current.Response.Cookies["UserName"].Expires = DateTime.MinValue;
HttpContext.Current.Response.Cookies["PwdTxt"].Expires = DateTime.MinValue;
}
页面这么调用的
这是在点击登陆时写的传值方法:sl.SavaPwd(SavePwdChk.Checked, UserNameTxt.Text, PwdTxt.Text);
页面调用是:
if (!IsPostBack)
{
if (Request.Cookies["UserName"] != null && Request.Cookies["Pwd"] != null)
{
UserNameTxt.Text = Request.Cookies["UserName"].Value.ToString();
PwdTxt.Attributes["value"] = Request.Cookies["Pwd"].Value.ToString();
}
}帮我看看是哪的错误谢了!!!!
public void SavaPwd(bool SavaPwdChk, string UserNameTxt, string PwdTxt)
{
if (SavaPwdChk == true)
{
HttpContext.Current.Response.Cookies["UserName"].Value = UserNameTxt;
HttpContext.Current.Response.Cookies["PwdTxt"].Value = PwdTxt;
HttpContext.Current.Response.Cookies["UserName"].Expires = DateTime.MaxValue;
HttpContext.Current.Response.Cookies["PwdTxt"].Expires = DateTime.MaxValue;
}
else
{
HttpContext.Current.Response.Cookies["UserName"].Expires = DateTime.MinValue;
HttpContext.Current.Response.Cookies["PwdTxt"].Expires = DateTime.MinValue;
}
页面这么调用的
这是在点击登陆时写的传值方法:sl.SavaPwd(SavePwdChk.Checked, UserNameTxt.Text, PwdTxt.Text);
页面调用是:
if (!IsPostBack)
{
if (Request.Cookies["UserName"] != null && Request.Cookies["Pwd"] != null)
{
UserNameTxt.Text = Request.Cookies["UserName"].Value.ToString();
PwdTxt.Attributes["value"] = Request.Cookies["Pwd"].Value.ToString();
}
}帮我看看是哪的错误谢了!!!!
类库中这么写的方法
public void SavaPwd(bool SavaPwdChk, string UserNameTxt, string PwdTxt)
{
HttpCookie cookieName = new HttpCookie["UserName"];
HttpCookie cookiePwd = new HttpCookie["Pwd"]; if (SavaPwdChk == true)
{
cookieName.Value = UserNameTxt;
cookieName.Expires = DateTime.Now.AddDays(1);
Response.AppendCookie(cookieName ); cookiePwd.Value = PwdTxt;
cookiePwd.Expires = DateTime.Now.AddDays(1);
Response.AppendCookie(cookiePwd);
}
else
{
cookieName.Expires = DateTime.Now.AddDays(-1);
cookiePwd.Expires = DateTime.Now.AddDays(-1);
}
if (!IsPostBack)
{
if (HttpContext.Current.Request.Cookies["UserName"].Value!= null && HttpContext.Current.Request.Cookies["Pwd"].Value!= null)
{
UserNameTxt.Text = Request.Cookies["UserName"].Value.ToString();
PwdTxt.Text = Request.Cookies["Pwd"].Value.ToString();
}
}