ChangePassword::OnChangingPassword Method
Raises the ChangingPassword event before the user's password is changed by the membership provider.
Assembly: System.Web (in System.Web.dll)
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.
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.