How to use ASP.NET Membership ChangePassword control

You can use this control when you want to allow the user to change his/her password. The control simply queries the user name as well as the old password from the user. Then it requires the user to enter the new password and confirm the new password. You can use the control on a secured page as follows:

The controls includes a MailDefinition child element with the same settings as the PasswordRecovery control. This is because after the password has been changed successfully, the control automatically can send an e-mail to the user’s e-mail address if a mail server is configured for the web application. You can customize through both properties and styles and a template-based approach. Two templates are required when customizing the control:

– The ChangePasswordTemplate displays the fields for entering the old user name and password as well as the new password, including the password confirmation field.

– The SuccessTemplate displays the success message, telling the user if the reset completed successfully or not.

The ChangePasswordTemplate requires you to add some special controls with special IDs and CommandName property values. You can find these control ID values and CommandName values in bold in the following code snippet:

The text box controls of the ChangePasswordTemplate are mandatory. The other controls are optional. If you select the ID properties and the CommandName properties for the buttons appropriately, you don’t have to write any additional code.