This was one of the questions I read on the www.asp.net forums. The question was how can I set the password in the password field. First, of all I must say that this is not a good idea the reason is security and anyone can come and use the password.


This was one of the questions I read on the www.asp.net forums. The question was how can I set the password in the password field. First, of all I must say that this is not a good idea the reason is security and anyone can come and use the password.

Second, can this actually be done? Well, if you try the following code it won't work.

TextBox1.Text = "mypassword"; (The TextBox TextMode is password).
But, this will work:

TextBox1.Attributes["Value"] = "mypassword";

The reason is that the server property Text does not allow you set the text when the textbox is in the password mode. But the "Value" property is not a server property and hence you can set it.