ChangePassword.DisplayUserName Property
Gets or sets a value indicating whether the ChangePassword control should display the UserName control and label.
Assembly: System.Web (in System.Web.dll)
abstract DisplayUserName : bool with get, set override DisplayUserName : bool with get, set
Property Value
Type: System.Booleantrue if the ChangePassword control should display the UserName; otherwise, false. The default is false.
In order to change their password, users must be authenticated by the membership provider. To allow users who are not logged on to change their password, or to be authenticated by the membership provider with a different user account and then change the password for that account, the ChangePassword control can display a TextBox control to accept the user name.
You must set the DisplayUserName property to true if the ChangePassword control will be displayed to users who are not logged on; otherwise, the user will not be able to specify a user name.
The following code example shows how to set the DisplayUserName property to display the UserName control to users who are not logged on to the Web site.
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 ChangingPassword 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 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.
Available since 2.0
ChangePassword Class
System.Web.UI.WebControls Namespace
ASP.NET Login Controls Overview
Customizing the Appearance of ASP.NET Login Controls
ASP.NET Web Server Controls Templates
How to: Display Different Information to Anonymous and Logged In Users
Web Site Administration Tool Security Tab
Securing Login Controls
Basic Security Practices for Web Applications
Securing Membership