At some stage I had to pre-fill a password field. Actually that is something you don’t want to do because the value can be seen in the plain html text. But perhaps you want to show some **** initially on a new user page or something.

ASP.NET won’t render the value of a TextBox with textmode set to password into the page, but you can force the required html to pre-fill password fields using the .AddAttribute(“value”, password); method on the control:

TextBox passwd = new TextBox() { TextMode = TextBoxMode.Password };
passwd.AddAttribute("value", "*****");

I already mentioned you can see the password in plain text in the html, so it is a bad idea to do that with real passwords. You should try to avoid this. But in some cases (i.e. display password strength / weakness during initial password entry on a “new user” page, with no real password but a dummy value) this totally makes sense.