Assigning the text value for a Password Textbox

Hi,

Setting the text property for a textbox with textmode=single and multiline is pretty straight forward by giving

TextBox1.Text = "The text we want to set";

However, if we set the Textmode property to Password, then we cannot simply set the text using the TextBox.text.

In practical scenarios, we may not want to set the password for obvious reasons that password is one which we retrieve from the user and it shoult not be set.

Also, even if we set some password, the user cannot read it as it is just a sequence of dots.

If, for however, due to specific reasons, we need to set the password, then we can do the same by using the following code:-

txtpasswd.Attributes.Add("value", "the password we wish to set");

Or, if you are assigning the password from the database you can use a DataReader in place of the actual password, as follows :

txtpasswd.Attributes.Add("value", objRdr["Password"].ToString());

Cheers.

posted @ Monday, April 25, 2005 7:45 AM

Print

Comments on this entry:

# re: Assigning the text value for a Password Textbox

Left by RDS at 12/3/2005 12:07 PM
Gravatar
How does this work on a mobile textbox?

# re: Assigning the text value for a Password Textbox

Left by Ralph Whitbeck at 12/19/2005 2:25 PM
Gravatar
Thank you. I was banging my head against the wall trying to figure out why it wasn't getting set with just a txtpass.Text = "Password";

# re: Assigning the text value for a Password Textbox

Left by Anandaraman at 1/16/2006 5:58 AM
Gravatar
Thanks a lot, this solution is very much useful.

# re: Assigning the text value for a Password Textbox

Left by omarir at 4/4/2007 9:55 AM
Gravatar
thank you for help. it was very useful for me.

# re: Assigning the text value for a Password Textbox

Left by lokesh Thakre at 5/12/2008 8:07 PM
Gravatar
How manay scienirio of the password text box
?
09998772434

# re: Assigning the text value for a Password Textbox

Left by Zeroark at 6/11/2009 8:10 PM
Gravatar
Thanks a lot for the help n_n

# re: Assigning the text value for a Password Textbox

Left by mario oyunları at 9/21/2009 10:47 AM
Gravatar
it was very useful for me.

Your comment:



 (will not be displayed)


 
 
 
 
 

Live Comment Preview:

 
«November»
SunMonTueWedThuFriSat
25262728293031
1234567
891011121314
15161718192021
22232425262728
293012345