Click here to Skip to main content
15,038,345 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have an application for in that i am doing the criteria of remember me.. But the value is not auto filling in text box any suggestions.......Thanks For Help
Posted
Comments
P_Dash 31-Jan-13 4:59am
   
Plz Mention what kind of App. is it ?
Also Do you just want to implement Remember me logic, so that user need not to input on next Login or Want to Autofill the ID/PWD Textboxes ?

Provide Details about your Problem.
[no name] 31-Jan-13 7:53am
   
its a asp.net Web Application.. I am using the following code..

if (chkRememberPassword.Checked == true)
{
Response.Cookies["UName"].Value = txtUName.Text;
Response.Cookies["PWD"].Value = txtPWD.Text;
Response.Cookies["UName"].Expires = DateTime.Now.AddMonths(2);
Response.Cookies["PWD"].Expires = DateTime.Now.AddMonths(2);
}
else
{
Response.Cookies["UName"].Expires = DateTime.Now.AddMonths(-1);
Response.Cookies["PWD"].Expires = DateTime.Now.AddMonths(-1);
}

For remember me......
BUt its stores only one value and doesnt store any value in autofilling in browser...
I had checked in other browser also but it will revert me same....

Basically remind functionality will be implement in login page to save the user details. this can be implemented with the help of cookies. cookies will store in browser.

Asp.net is providing login controls along with remind me next time in built in option. any way here is the custom code for remind me next time.

if (chkRememberPassword.Checked == true) 
{ 
Response.Cookies["UName"].Value = txtUName.Text; 
Response.Cookies["PWD"].Value = txtPWD.Text; 
Response.Cookies["UName"].Expires = DateTime.Now.AddMonths(2); 
Response.Cookies["PWD"].Expires = DateTime.Now.AddMonths(2); 
} 
else 
{ 
Response.Cookies["UName"].Expires = DateTime.Now.AddMonths(-1); 
Response.Cookies["PWD"].Expires = DateTime.Now.AddMonths(-1); 
} 


Paste the following code snippet in page load

if (!IsPostBack) 
{ 
if (Request.Cookies["UName"] != null) 
txtUName.Text= Request.Cookies["UName"].Value; 
if (Request.Cookies["PWD"] != null) 
txtPWD.Text.Attributes.Add("value", Request.Cookies["PWD"].Value); 
if (Request.Cookies["UName"] != null && Request.Cookies["PWD"] != null) 
chkRememberPassword.Checked = true; 
} 
   
Comments
[no name] 31-Jan-13 7:57am
   
Dear Schristmas,

Thanks for response.
I have tried this code only but it doesnt allow the second value to populated in text box..
I have tried all the posibilities like Autocomplete = "on" or Autocomplete = "True" ...

regards
Sandesh M Patil 31-Jan-13 8:32am
   
Dont save password in cookies. if this answer help you upvote it :)
As per your requirement the following code will help you for sure.

1st of all Write the following Code inside the Login Button after your validation code:
C#
protected void Button1_Click(object sender, EventArgs e)
    {
        HttpCookie  obj=new HttpCookie("Identity");
        obj.Values["UName"]=tbUser.Text;
        obj.Values["Pwd"]=tbPwd.Text;
        Response.Cookies.Add(obj);
        if (cbRemember.Checked)
            obj.Expires = DateTime.Now.AddMonths(3);
        else
            obj.Expires = DateTime.Now.AddMonths(-1);
    }

Now write the following code inside Page_Load event:
C#
protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Request.Cookies["Identity"] != null)
            {
                tbUser.Text = Request.Cookies["Identity"]["UName"].ToString();
                tbPwd.Attributes.Add("value", Request.Cookies["Identity"]["Pwd"].ToString());
                cbRemember.Checked = true;
            }
        }
    }

I've tested this code in my System & It's working fine.
Use it & Accept as Solution if get your Result.
   
Comments
[no name] 4-Feb-13 8:10am
   
totally messed up.. In my other applications its working perfeclty but not in this application.. Can any body help me...
P_Dash 4-Feb-13 10:58am
   
I don't understand How is it Possible that it's working in Other Applications but not in current ???
Annoying Man.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900