If you have a page with an <asp:TextBox TextMode="Password" ... />
.
How can you keep the value after a postback?
This is my problem:
At the registration screen of my app you need to enter a password.
Then you click submit, a postback occurs and the password fields are cleared, how can I prevent the password field from clearing?
The <input type="password"> defines a password field (characters are masked). Note: Any forms involving sensitive information like passwords should be served over HTTPS. Tip: Always add the <label> tag for best accessibility practices!
One of the common interview question is “Explain the use of ViewState for TextBox?” and the most popular and common answer for this question is view state will maintain the text property value of the TextBox after a PostBack of the page.
<input type = "password" > Thus the entered characters are masked or hidden. To make a textbox that can hide the entered characters, the type attribute of <input> element should be set to "password."
You require to set it again in page_load or in button click event like this :
string Password = txtPassword.Text;
txtPassword.Attributes.Add("value", Password);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With