Usually when we need to set values for textboxes dynamically, we just assign values to the Textbox's Text property like,
TextBox1.Text = "hsp";
But the above statement will not work, if the Textbox mode is "Password".
Suppose we want to set the values of Password mode textbox, we can use the following code.
TextBox1.Attributes["value"] = "hsp";
Also, when the page is getting postback, the values in Password textboxes will be cleared. But you can retain the text in password textboxes.
Add the following code in Page_Load event of the page.
TextBox1.Attributes.Add("value", TextBox1.Text);
No comments:
Post a Comment