ASP.NET Textbox Prob on AutoPostback

I have an ASP.NET page with four textboxes.  

First two are FirstName and LastName.  The values are populated from the database.

The next two are Password and ConfirmPassword.  When I enter a value in the Password text box and click on the submit button the value disappears from the Password textbox.

Any idea how to resolve?
LVL 2
CipherISAsked:
Who is Participating?
 
Rajar AhmedConsultantCommented:
well can be achieved like this  and its simple  but will lose the security design measure as data's will be stored as plain text
 txtPersist.Attributes.Add("value", txtPersist.Text)
So, its better to leave as it is , but u  can always take a decision whether to use it or not
 
Some other method :
http://www.codeproject.com/Articles/18927/How-to-safely-keep-a-password-field-during-postbac

Go thro the comments on this blog :
http://ryanfarley.com/blog/archive/2004/12/18/1300.aspx
0
 
Guru JiCommented:
You can try putting this in your password textbox

onkeydown = "return (event.keyCode!=13);"

this will disable to autopostback on that textbox which will help u to retain the password when clicking submit
0
 
Guru JiCommented:
Sample textbox

<asp:TextBox ID="TextBox1" runat="server"

   onkeydown = "return (event.keyCode!=13);" >

</asp:TextBox>

You can also do codebehind like this if using c#
TextBox1.Attributes.Add("onkeydown", "return (event.keyCode!=13);");
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
CipherISAuthor Commented:
the issue is i have not identified the textbox as a password yet.  I am testing it and exposing the text being typed.  It disappears as soon as i click on the submit button and the value = "".
0
 
CipherISAuthor Commented:
below does not work

TextBox1.Attributes.Add("onkeydown", "return (event.keyCode!=13);");
0
 
CipherISAuthor Commented:
I figured it out.  It was a coding issue.  On the load event I was setting the value = string.empty.
0
 
CipherISAuthor Commented:
Figured it out
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.