This documentation is archived and is not being maintained.

ChangePassword.ChangingPassword Event

Occurs before the password for a user account is changed by the membership provider.

Namespace:  System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)

member ChangingPassword : IEvent<LoginCancelEventHandler,
    LoginCancelEventArgs>

<asp:ChangePassword OnChangingPassword="LoginCancelEventHandler" />

The ChangingPassword event is raised before the membership provider specified in the MembershipProvider property is called to change the password for a user account.

Use the ChangingPassword event to perform any processing that is necessary before changing the password, such as checking the new password to make sure it is not in a list of common passwords. The new authorization token for the user is set after the ChangingPassword event but before the ChangedPassword event.

The ChangingPassword event can be canceled by setting the Cancel property of the LoginCancelEventArgs object to true if the event handler determines that the membership provider should not be called.

For more information about handling events, see Handling and Raising Events.

The following code example shows how to use an ASP.NET page that uses a ChangePassword control, and includes a handler for the ChangingPassword event named ChangingPassword. The code in the event handler compares the old password stored in the CurrentPassword property to the new password stored in NewPassword. If the two passwords are the same, changing the password fails.

The ChangePassword control sets the DisplayUserName property to true to enable users to enter their user name. This means that the user does not have to log on to view the page.

The code example assumes that the ASP.NET Web site has been configured to use ASP.NET membership and Forms authentication, and that a user has been created whose name and password are known to you. For more information, see How to: Implement Simple Forms Authentication.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Show: