This documentation is archived and is not being maintained.

ChangePassword.OnChangingPassword Method

Raises the ChangingPassword event before the user's password is changed by the membership provider.

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

abstract OnChangingPassword : 
        e:LoginCancelEventArgs -> unit 
override OnChangingPassword : 
        e:LoginCancelEventArgs -> unit 

Parameters

e
Type: System.Web.UI.WebControls.LoginCancelEventArgs
A CancelEventArgs object containing the event data.

The OnChangingPassword method is called before the membership provider specified in the MembershipProvider property is called to change the user's password.

Use the OnChangingPassword method 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 OnChangingPassword method can cancel the ChangingPassword event by setting the Cancel property of the CancelEventArgs object passed as the e parameter to true.

Raising an event invokes the event handler through a delegate. For more information, see Server Event Handling in ASP.NET Web Pages.

The OnChangingPassword method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class.

Notes to Inheritors

When overriding the OnChangingPassword method in a derived class, be sure to call the OnChangingPassword method for the base class so that registered delegates receive the event.

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. ChangingPassword 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 the user 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: