asp.net.ph

ChangePassword Class

System.Web.UI.WebControls Namespace


.NET Framework version 2.0

Provides a user interface that enable users to change their Web site password.

ChangePassword Class Members

Collapse   Constructors

Visibility Constructor Parameters
public ChangePassword ( )

Collapse   Fields

Visibility Name Type
public static CancelButtonCommandName String
public static ChangePasswordButtonCommandName String
public static ContinueButtonCommandName String

Collapse   Properties

Visibility Name Value Type Accessibility
public BorderPadding Int32 [ Get , Set ]
public CancelButtonImageUrl String [ Get , Set ]
public CancelButtonStyle Style [ Get ]
public CancelButtonText String [ Get , Set ]
public CancelButtonType ButtonType [ Get , Set ]
public CancelDestinationPageUrl String [ Get , Set ]
public ChangePasswordButtonImageUrl String [ Get , Set ]
public ChangePasswordButtonStyle Style [ Get ]
public ChangePasswordButtonText String [ Get , Set ]
public ChangePasswordButtonType ButtonType [ Get , Set ]
public ChangePasswordFailureText String [ Get , Set ]
public ChangePasswordTemplate ITemplate [ Get , Set ]
public ChangePasswordTemplateContainer Control [ Get ]
public ChangePasswordTitleText String [ Get , Set ]
public ConfirmNewPassword String [ Get ]
public ConfirmNewPasswordLabelText String [ Get , Set ]
public ConfirmPasswordCompareErrorMessage String [ Get , Set ]
public ConfirmPasswordRequiredErrorMessage String [ Get , Set ]
public ContinueButtonImageUrl String [ Get , Set ]
public ContinueButtonStyle Style [ Get ]
public ContinueButtonText String [ Get , Set ]
public ContinueButtonType ButtonType [ Get , Set ]
public ContinueDestinationPageUrl String [ Get , Set ]
public CreateUserIconUrl String [ Get , Set ]
public CreateUserText String [ Get , Set ]
public CreateUserUrl String [ Get , Set ]
public CurrentPassword String [ Get ]
public DisplayUserName Boolean [ Get , Set ]
public EditProfileIconUrl String [ Get , Set ]
public EditProfileText String [ Get , Set ]
public EditProfileUrl String [ Get , Set ]
public FailureTextStyle TableItemStyle [ Get ]
public HelpPageIconUrl String [ Get , Set ]
public HelpPageText String [ Get , Set ]
public HelpPageUrl String [ Get , Set ]
public HyperLinkStyle TableItemStyle [ Get ]
public InstructionText String [ Get , Set ]
public InstructionTextStyle TableItemStyle [ Get ]
public LabelStyle TableItemStyle [ Get ]
public MailDefinition MailDefinition [ Get ]
public MembershipProvider String [ Get , Set ]
public NewPassword String [ Get ]
public NewPasswordLabelText String [ Get , Set ]
public NewPasswordRegularExpression String [ Get , Set ]
public NewPasswordRegularExpressionErrorMessage String [ Get , Set ]
public NewPasswordRequiredErrorMessage String [ Get , Set ]
public PasswordHintStyle TableItemStyle [ Get ]
public PasswordHintText String [ Get , Set ]
public PasswordLabelText String [ Get , Set ]
public PasswordRecoveryIconUrl String [ Get , Set ]
public PasswordRecoveryText String [ Get , Set ]
public PasswordRecoveryUrl String [ Get , Set ]
public PasswordRequiredErrorMessage String [ Get , Set ]
public RenderOuterTable Boolean [ Get , Set ]
public SuccessPageUrl String [ Get , Set ]
public SuccessTemplate ITemplate [ Get , Set ]
public SuccessTemplateContainer Control [ Get ]
public SuccessText String [ Get , Set ]
public SuccessTextStyle TableItemStyle [ Get ]
public SuccessTitleText String [ Get , Set ]
public TextBoxStyle Style [ Get ]
public TitleTextStyle TableItemStyle [ Get ]
public UserName String [ Get , Set ]
public UserNameLabelText String [ Get , Set ]
public UserNameRequiredErrorMessage String [ Get , Set ]
public ValidatorTextStyle Style [ Get ]

Collapse   Methods

Visibility Name Parameters Return Type
protected LoadViewState ( Object savedState ) Void
protected OnBubbleEvent ( Object source , EventArgs e ) Boolean
protected OnCancelButtonClick ( EventArgs e ) Void
protected OnChangedPassword ( EventArgs e ) Void
protected OnChangePasswordError ( EventArgs e ) Void
protected OnChangingPassword ( LoginCancelEventArgs e ) Void
protected OnContinueButtonClick ( EventArgs e ) Void
protected OnSendingMail ( MailMessageEventArgs e ) Void
protected OnSendMailError ( SendMailErrorEventArgs e ) Void
protected SaveViewState ( ) Object
protected SetDesignModeState ( IDictionary data ) Void
protected TrackViewState ( ) Void

Remarks

Use the ChangePassword control on a page to enable your Web site users to change the passwords they use to log on to your Web site.

NOTE: Transmitting passwords over HTTP is a potential security threat. HTTP transmissions can be viewed or compromised by malicious users. To improve security when using login controls, you should use HTTPS protocol with secure sockets layer ( SSL ) encryption to ensure that the user's password cannot be read during postback. For more information, see Securing Login Controls.

The ChangePassword control uses the membership provider defined in the MembershipProvider property to change the password stored in the membership provider data store for the Web site. If you do not assign a membership provider, the ChangePassword control uses the default membership provider defined in the membership section of the Web.config file. The ChangePassword control enables users to perform the following actions:

  • Change their password if they are logged on.
  • Change their password if they are not logged on, as long as the page that contains the ChangePassword control allows anonymous access and the DisplayUserName property is true.
  • Change the password for a user account, even if they are logged on as a different user. This requires the DisplayUserName property to be true.

Setting the DisplayUserName property to true displays the User Name text box, which allows the user to type in a user name. If the user is logged on, the UserName control is populated with the name of the logged-on user. After the password for the given user name is changed, the user is logged on to the account associated with the changed password, even if the user was not logged on to that account previously.

NOTE: Accepting user input is a potential security threat. Malicious users can send data that is intended to expose vulnerabilities or run programs that try generated passwords. To improve security when working with user input, you should use the validation features of your control and secure any data providers that are configured for your control. For more information, see Securing Login Controls, Basic Security Practices for Web Applications, and Securing Membership.

Sending E-mail Messages

The ChangePassword control can be configured to use e-mail services to send the new password to the user. To send e-mail messages to users from any of ASP.NET Web server controls, you must configure an e-mail server in the Web.config file for your application. For more information, see How to: Install and Configure SMTP Virtual Servers in IIS.

E-mail messages are configured using the MailDefinition class. You must set the BodyFileName property to instruct ASP.NET to send e-mail.

NOTE: Sending user account names or passwords in e-mail is a potential security threat. E-mail messages are typically sent in plain text and can be read by special network "sniffing" applications. To improve security, use the mitigations that are described in Securing Login Controls.

Views

The ChangePassword control has two states, or views:

Change Password view
Requests the current password, and requires the user to type the new password twice for confirmation. If you allow users who are not logged on to change their passwords, set the DisplayUserName property to true to display the UserName control in Change Password view. The UserName control allows the user to provide their registered user name. If there is an error when changing the password, an error message is displayed in the Change Password view, allowing the user to try again.
Success view
Provides confirmation that the password has been changed.

Styles and Templates

You can use an extensive set of style properties to customize the appearance of the ChangePassword control. Alternatively, you can apply custom templates to the two views if you need complete control over the appearance of the ChangePassword control. If you define a template for a view, the ControlStyle properties are applied. For a list of the controls that you must set in the view templates, see the ChangePasswordTemplate and SuccessTemplate properties. The ChangePassword control examines the content in the template and throws an exception if a required control is not found, is not named correctly, or is of the wrong type. For example, if you use the content in the template and set the DisplayUserName property to true, the ChangePassword will throw an exception if a TextBox or some other IEditableTextControl control is not found for the user name.

The following table lists the ChangePassword control style properties and describes which UI element they affect. For a list of the properties to which each style applies, see the individual style property.

ChangePassword style property UI element
CancelButtonStyle Cancel button on the Change Password view.
ChangePasswordButtonStyle Change password button on the Change Password view.
ContinueButtonStyle Continue button on the Success view.
FailureTextStyle Error text displayed to the user.
HyperLinkStyle Hyperlinks to other pages.
InstructionTextStyle Instructional text on the page that describes how to use the ChangePassword control.
LabelStyle Labels for all input fields, such as text boxes.
PasswordHintStyle Hints for providing an acceptable password for the Web site.
SuccessTextStyle Text displayed to the user when the password has been successfully changed.
TextBoxStyle Text entry input fields.
TitleTextStyle Titles for the Change Password and Success views.

Validation Groupings

The ChangePassword control uses a validation group so that other fields on the same page as the ChangePassword control can be validated separately. By default, the ID property of the ChangePassword control is used as the name of the validation group. For example, a ChangePassword control with the ID "ChangePassword1" will use a validation group name of ChangePassword1 as well. To set the validation group that the ChangePassword control is part of, you must create a template with the control, and then change the validation group name.

To show error messages if a user leaves a TextBox control empty, add a ValidationSummary control to the page. Set the ValidationGroup property of the ValidationSummary control to the ID property of the ChangePassword control.

Accessibility Features

If the ChangePassword control is not customized with templates, the AccessKey property of the ChangePassword control applies to the first text box in the control. If the ChangePassword control is customized with templates, then the AccessKey property is ignored. In that case, set the AccessKey property of each template child control directly. The TabIndex property is rendered on all the TextBox controls in the ChangePassword control. If the ChangePassword control is customized with templates, then the TabIndex property is ignored.

Accessing Controls During Page_Load and Page_Init

ChangePassword control properties represented by text boxes, such as UserName and CurrentPassword, are accessible during all phases of the page life cycle. In particular, during the Page_Init and Page_Load phases, these properties have the same value they had when the ChangePassword control was rendered. If the user changes the value of the UserName property by modifying the UserName text box, the new value will be available when the changed event is raised, which occurs after the Page_Load phase. Therefore, if you set the value of the UserName property in the Page_Init phase or Page_Load phase and provide a custom handler for a ChangePassword event, any change that the user makes in the UserName text box overrides the value set in the Page_Init or Page_Load phase.

For examples illustrating use of this control, see the individual member types of this class. For syntax information, see ChangePassword in ASP.NET Syntax for Web Controls.

See Also

ASP.NET Login Controls   ChangePassword Web Server Control Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph