When you are using a textbox for a password field in .NET and hence have its TextMode property set to 'Password' you cannot set the Text property of the textbox at runtime. This is a bit of a pain but is by design to prevent an unmasked password being displayed in the page.
Sometimes we may however want to override this behaviour. This can be done by simply setting the value attribute instead of using the Text property as below:
PasswordText.Attributes.Add("value", "ThePassword");