Reputation: 23
I have problem with password text box control. I have username textbox, password textbox, retypepassword textbox. And i have drowpdownlist with items Website, Newspaper, Others. After filling username, password, retype password in textbox. Whenever i am selecting items Newspaper and Others items from drowdownlist, password and retypepassword textbox value getting cleared. I have set in autopostback=true in dropdownlist control. Pls somebody help me where is my mistake??
Thanks, Sumit
Upvotes: 0
Views: 3818
Reputation: 316
In the dropdown_SelectedIndexChanged(object sender, EventArgs e)
method set the password field and confirmpassword field
txtPassword.Attributes.Add("value",txtPassword.Text);
txtconfirmPassword.Attributes.Add("value", txtconfirmPassword.Text);
And again in the submit button click you have to clear the password field like the below
txtPassword.Attributes["value"] = "";
txtconfirmPassword.Attributes["value"] = "";
Upvotes: 0
Reputation: 7941
You can put the DropDownList onto an UpdatePanel. Or use JavaScript instead of server side postback.
Upvotes: 1
Reputation: 43168
As Quintin indicated, this is by design. TextBox.Text
does not get persisted when TextMode
is "Password". You can work around this by setting
txtPassword.Attributes[ "value" ] = txtPassword.Text;
some time during page processing.
Upvotes: 6
Reputation: 82325
It's not a mistake it's just that passwords won't be sent back to the client after a postback, this is by design. What is your intent?.. is there a reason you would like the password boxes to persist through postbacks?
Upvotes: 4