dotnetspider.com
Login Login    Register      

TutorialsForumCareer DevelopmentResourcesReviewsJobsInterviewCommunitiesProjectsTraining

Subscribe to Subscribers
Talk to Webmaster
Tony John

Facebook
Google+
Twitter
LinkedIn
Online MembersPhagu Mahato
More...
Join our online Google+ community for Bloggers, Content Writers and Webmasters




Forums » .NET » ASP.NET »

Remember Password on Next login


Posted Date: 17 Aug 2012      Posted By:: baboo     Member Level: Silver    Member Rank: 1093     Points: 5   Responses: 2



Sir,

I created website using asp.net with c#.Design and Source Coding is as

follows.

Design

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="txtUserName" runat="server"></asp:TextBox>
</div>
<div>
<asp:TextBox ID="txtPassword" runat="server" TextMode="Password" AutoCompleteType="DisplayName"></asp:TextBox>
</div>
<div>
<asp:CheckBox ID="chk" runat="server" />
</div>
<div>
<asp:Button ID="btnLogin" runat="server" Text="Login" onclick="btnLogin_Click" />
</div>
</form>
</body>
</html>

Source Coding

public partial class WebForm1 : System.Web.UI.Page
{
HttpCookie myCookie = new HttpCookie("yourInfo");
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Request.Cookies["UName"] != null)
txtUserName.Text = Request.Cookies["UName"].Value;
if (Request.Cookies["PWD"] != null)
txtPassword.Attributes.Add("value",Request.Cookies["PWD"].Value);
}
}

protected void btnLogin_Click(object sender, EventArgs e)
{
if (chk.Checked == true)
{
Response.Cookies["UName"].Value = txtUserName.Text;
Response.Cookies["PWD"].Value = txtPassword.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);
}
}
}

i stored username and password in cookie as follows.

username - Ram

password - ram

username - Mahesh

password - mahesh

i typed username as Ram in txtUserName.

when i focus on txtPassword, ram should be filled automatically in txtPassword.

i need coding in asp.net using c# for this concept.

its urgent.

send me immediately.

Thanks in advance.




Responses

#684655    Author: Prasad kulkarni        Member Level: Diamond      Member Rank: 8     Date: 18/Aug/2012   Rating: 2 out of 52 out of 5     Points: 4

You can use Javascipt to set password to password textbox.
"onblur" event of username textbox set the cookies.


<script language="Javascript">
function getCookieValue(CookieName)
{
var iCount,varCookiesName,y;
var arrCoo =document.cookie.split(";")

for (iCount=0; iCount<arrCoo.length; iCount++)
{
varCookiesName=arrCoo[iCount].substr(0,arrCoo[iCount].indexOf("="));
y=arrCoo[iCount].substr(arrCoo[iCount].indexOf("=")+1);
varCookiesName=varCookiesName.replace(/^\s+|\s+$/g,"");
if (varCookiesName == CookieName)
{
//set return value to Password TextBox
document.getElementById("txtPass").value = unescape(y);
}
}
}
</script>

//call above javascript function on "onblur" event of Username Textbox
<asp:TextBox id="txtUserName" runat="Server" onblur="return setCookieValue()">


hope it helps

Thanks
Koolprasd2003
[DotNetSpider MVM]



 
#684661    Author: saravanakumar      Member Level: Gold      Member Rank: 195     Date: 18/Aug/2012   Rating: 2 out of 52 out of 5     Points: 2

use login controls.that login control have username,password field, remember password,
u just check the user info(Login_authenticate Event) and set the cookies.

loginname control is used to display the username.and that is help to develop the forms based authentication system.



 
Post Reply
You must Sign In to post a response.

Next : Popup postion of calender extender control is not reflecting..
Previous : How to implement automatic Scrolling News
Return to Discussion Forum
Post New Message
Category:

Related Messages



Follow us on Twitter: https://twitter.com/dotnetspider

Active Members
TodayLast 7 Daysmore...

Awards & Gifts
Email subscription
  • .NET Jobs
  • .NET Articles
  • .NET Forums
  • Articles Rss Feeds
    Forum Rss Feeds


    About Us    Contact Us    Copyright    Privacy Policy    Terms Of Use    Revenue Sharing sites   Advertise   Talk to Tony John
    Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India
    2005 - 2012 All Rights Reserved.
    .NET and other trademarks mentioned in this site belong to Microsoft and other respective trademark owners.
    Articles, tutorials and all other content offered here is for educational purpose only.
    We are not associated with Microsoft or its partners.