问题描述
你好,民谣
我有一个登录表单,如果我选中记住我"复选框,那么我想记住用户名和密码..
上面的代码用于记住我..功能...它工作正常,但只有一个问题...选中记住我"复选框后..如果我重新加载登录页面,选中的记住不保存"可以帮助我如何重新爱护我这个问题.....
谁能帮我...
我的代码就是这种方式...........请记住我...
下面的代码工作正常,只有问题检查了才记得还没有....
Hi folk''s
I have a login form in that if i check the remember me check-box,then i want to remember username and password ..
above code is for remember me.. functionality...it is working fine but only one problem ...After checking remember me check box.. if i reload login page the checked remember not remains can any one help me how can i reslove this problem.....
Can any one help me......
My code is in this way..........for remember me .....
Below code is working fine only problem is checked remember is not remains ....
protected void Page_Load(object sender, EventArgs e)
{
if (Page.IsPostBack)
{
if (chk_rem.Checked)
{
HttpCookie mycookie1 = new HttpCookie("mycookie1");
//Response.Cookies.Remove("mycookie1");
Response.Cookies.Add(mycookie1);
mycookie1.Values.Add("Username", txt_username.Text);
mycookie1.Values.Add("Password", txt_password.Text);
DateTime dtex = DateTime.Now.AddDays(15);
if (chk_rem.Checked == true)
{
if (Request.Cookies["mycookie1"] != null)
{
HttpCookie getcookie1 = Request.Cookies.Get("mycookie1");
string un = getcookie1.Values["Username"].ToString();
string ps = getcookie1.Values["Password"].ToString();
}
}
}
if (chk_rem.Checked == false)
{
Response.Cookies["mycookie1"].Expires = DateTime.Now.AddDays(-1);
}
}
if (HttpContext.Current.Request.Cookies["mycookie1"] != null)
{
try
{
txt_username.Text = HttpContext.Current.Request.Cookies["mycookie1"]["Username"].ToString();
string a = HttpContext.Current.Request.Cookies["mycookie1"]["Password"].ToString();
txt_password.Attributes.Add("value", a);
chk_rem.Checked = true;
}
catch { }
}
}
谢谢's& Regard's
mahesh.bpc
Thank''s&Regard''s
mahesh.b.p.c
推荐答案
这篇关于记得我问题检查过的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!