Click here to Skip to main content
12,510,006 members (56,318 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# ASP.NET
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 30-Jan-13 22:55pm
Comments
Gittu 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.
viral1986 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....
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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; 
} 
  Permalink  
Comments
viral1986 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
SChristmas 31-Jan-13 8:32am
   
Dont save password in cookies. if this answer help you upvote it :)
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

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:
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:
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.
  Permalink  
Comments
viral1986 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...
Gittu 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)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web01 | 2.8.160929.1 | Last Updated 1 Feb 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100