Saturday, January 2, 2010

Assigning Value to Password Input Field

In this short post I will show you how you can set the value in the Textbox which is used for the password. I have came across this problem in my development and now I want to share this with you. Like normal text box you can't assign value to the password field. Here is the my default form for the example. I have two text box one for the login name and second one for the password, And two button one for the sign in and second one for the clear.


And here is the small piece of code which is used to assign value to the text box field which has textMode to password. and Also statement used to clear the password field.
//Use to assign value to the TextBox of type Password
txtPassword.Attributes.Add("value", "somePassword");

//Use to clear value to the TextBox of type Password
txtPassword.Attributes.Add("value", "");

All and any comments / bugs / suggestions are welcomed!

No comments: