Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ASP.NET C# Set Value to Password Textbox in Code Behind
10-13-2010, 07:37 AM
Post: #1
ASP.NET C# Set Value to Password Textbox in Code Behind
If ever you've tried setting value in code-behind to a textbox with TextMode property set to "Password", you would notice it doesn't display the masked text on the page. This is simply the way it is for security purposes, but there is a workaround so you can show the user there is actually text in the textbox.

Here is the snippet:

txt1.Text = "sample_password";

if (txt1.TextMode == TextBoxMode.Password)
    txt1.Attributes.Add("value", txt1.Text);
Just set the same text value to the javascript attribute "value" and you're done.

Please give reputation if my answer/post is useful for you
Best Regards
Arti Gupta

Possibly Related Threads...
Thread: Author Replies Views: Last Post
  Convert code .Net4.0 to code .Net 2.0 dongtrien 0 911 04-21-2016 03:16 AM
Last Post: dongtrien
  Hash the existing Clear Password in aspnet membership gopal_nivas 0 1,129 02-20-2014 07:08 AM
Last Post: gopal_nivas
  creating and maintain data in dynamic textbox using asp.net nisar87 12 7,417 09-10-2012 11:14 AM
Last Post: darklord
Wink Encrypt and Decrypt Password sankkrit 1 7,772 01-23-2012 06:20 AM
Last Post: Jayakumar
  pdf to image webapp code asp.net nisar87 5 15,691 08-04-2011 01:07 PM
Last Post: nisar87

User(s) browsing this thread: 1 Guest(s)