Introduction
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.
When do we need this ? 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");
Password Value from Database
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.
Summary In this article we discussed a simple example on how to set the Text Value for a TextBox with TextMode as Password.
|
No responses found. Be the first to respond and make money from revenue sharing program.
|