remember me in login form

匿名 (未验证) 提交于 2019-12-03 01:25:01

问题:

I had Login form ,and I added check box for remember me ,I did my code well but when I check rememeber me check box it rememeber only user name only.so please any one help me.

protected void CBRemeber_CheckedChanged(object sender, EventArgs e)     {         HttpCookie MyCookie = new HttpCookie("MyCookie");         bool IsRememberme = CBRemeber.Checked;         if (IsRememberme)         {             MyCookie.Values.Add("UserName", TxtUser.Text);             MyCookie.Values.Add("Password", TXTPassword.Text);             MyCookie.Expires = DateTime.Now.AddDays(15);          }         else         {             MyCookie.Values.Add("UserName", string.Empty);             MyCookie.Values.Add("Password", string.Empty);             MyCookie.Expires = DateTime.Now.AddDays(5);          }         Response.Cookies.Add(MyCookie);     }

回答1:

You can't set the value of an ASP.NET Textbox control with TextMode="Password". Instead you can use a plain HTML element,

<input id="tbPassword" type="password" value="Hello World!" />

which wil let you set the value. Server you can retrieve the value on postbacks using Request.Form.

Also note if you're using the built-in ASP.NET Login control, the "Remember Me" checkbox behaves a little different than what you might expect.



转载请标明出处:remember me in login form
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!