Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 784
  • Last Modified:

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?
0
CipherIS
Asked:
CipherIS
  • 4
  • 2
2 Solutions
 
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
 
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:
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
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 
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

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now