Pages

Search This Blog

Tuesday, August 21, 2007

Display ***** in asp.net TextBox when TextMode = "Password"

The TextBox with TextMode = "Password" will be empty after assign a value using txtPassword.Text = Password
In Order to make it work and display ***** in the TextBox, replace
txtPassword.Text = Password;
with below method. This will work
txtPassword.Attributes.Add("value", Password);

4 comments:

Joel said...

If you do this your passwords will be exposed when someone views source.

In blues said...

Thanks for comment.I think it's depend on how we want to use it.

Anonymous said...

Yes the password would be exposed when someone views the source or uses a packet snooper. To prevent that, you could use SSL to access the page.

Myself, I have been looking this solution for awhile.

AB said...

Hello, regarding asp.net textbox using textmode=password. I need the textbox to display "****" - asteriks but it is displaying "....." - dots. I found out that windows forms textbox class has a property called PasswordChar but textbox WEB control does not have that property. How can I set that as asteriks??