Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Login Control -- Password, ASP.net 2.0

Posted on 2011-03-22
5
Medium Priority
?
1,258 Views
Last Modified: 2012-05-11
Hi,
Using login control in my login.aspx page . when ever user checks "Remember me"  userId is stored in cokkie.
At Next login, userID is filled automatically.
This works fine....

Now i'm trying to do the same ..for teh password .... by storing password in cookie and at next login ...fill the password ...
BUt, i am getting this error when i'm trying to fill the Login.Password filed using ...
Login2.Password = Server.HtmlEncode(Request.Cookies["pwd"].Value);
Error:- Property or indexer 'System.Web.UI.WebControls.Login.Password' cannot be assigned to -- it is read only

can i accomplish what i need?
0
Comment
Question by:kishan66
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 10

Expert Comment

by:Nash2334
ID: 35192204
First off, it's a bad idea to store passwords in cookies.  But if you are dead set on doing this, you can access the password textbox by using FindControl, then set the text property of that TextBox.

Login login = (Login)MyLoginView.FindControl("LoginUser");

if (login != null)
    TextBox passwordTextBox = (TextBox)login.FindControl("Password");

if (passwordTextBox != null)
    passwordTextBox.Text = "mypassword"
0
 

Author Comment

by:kishan66
ID: 35192479
Hi Nash 2334,

Though there is no error, password is not loaded automatically. Although userid is.

When i tried to debugg using the break points , under control Login2 -> Login2.Pawword  ="" & Login2.UserName = "username"

even though i'm using this line...
                TextBox mypassword = (TextBox)Login2.FindControl("Password");
               mypassword.Text = Server.HtmlEncode(Request.Cookies["pwd"].Value);
NO LUCK sir...
0
 
LVL 10

Accepted Solution

by:
Nash2334 earned 2000 total points
ID: 35193970
Sorry, use Attributes.Add:

mypassword.Attributes.Add("value", Request.Cookies["pwd"].Value);
0
 

Author Comment

by:kishan66
ID: 35194023
Thank you very much dude....  right on the spot.

i know its not good to save cookie with password on client pc, but i will try to encrypt and save it on clients pc and decrypt to authenticate.

would appreciate if you can suggest me one method or point me to best url..

can't ask more...
0
 
LVL 10

Expert Comment

by:Nash2334
ID: 35194191
You can use the FormsAuthentication encrypt method.  Good MSDN article here, very straightforward:

http://msdn.microsoft.com/en-us/library/system.web.security.formsauthentication.encrypt.aspx

Good luck.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question