i




 
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:

Code:
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
Quote


Possibly Related Threads...
Thread: Author Replies Views: Last Post
  Hash the existing Clear Password in aspnet membership gopal_nivas 0 404 02-20-2014 07:08 AM
Last Post: gopal_nivas
  creating and maintain data in dynamic textbox using asp.net nisar87 12 4,504 09-10-2012 11:14 AM
Last Post: darklord
Wink Encrypt and Decrypt Password sankkrit 1 5,401 01-23-2012 06:20 AM
Last Post: Jayakumar
  pdf to image webapp code asp.net nisar87 5 9,798 08-04-2011 01:07 PM
Last Post: nisar87
  Gridview Code asp.net praveen 0 1,145 05-08-2011 05:37 AM
Last Post: praveen



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