How to prevent a password input from clearing after submit?

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);

Best way

dont set input type in aspx page, set type of input in Pageload in !postback Section

txtPassword.Attributes["type"] = "password";

You need to set back the password to the textbox on postback.

txtBox.Attributes["value"] = txtBox.Text;

<input type="password" /> is treated differently than other form controls since it stores sensitive information that is a password of a user. At server side, for every postback the password textbox is force-fully cleared for this reason, should you really need to persist the value in password text-box, set it explicitly as others have mentioned here. But I really don't recommend doing so since it's not a good practice.