System.Web.UI.WebControls Namespace
.NET Framework version 2.0
Provides a user interface that enable users to change their Web site password.
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 ] |
|
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.
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.
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.
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.
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.
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.
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.
ASP.NET Login Controls ChangePassword Web Server Control