Recently i struggled a lot to set the value for the password field in my 2.0 application. In my application i generate the control dynamically based on data type of that field like checkbox for bit data type, textbox for string data type etc., But to my surprise we can’t set the text property of a Password Type field for security reasons. so i tried different ways to set the password field using javascript and hidden field. The problem in that approach is the user can go into view source and see it as clear text. After spending so many hours i came to find this solution which is very simple and elegant solution. we have to set the value as an attribute of the text box. The typical format for the same is.

txtPassword.Attributes.Add(“value”, PasswordValue)