The ASP.NET membership Login control provides additional customization properties you can use to manage its UI, except ones described in the article How to manage ASP.NET membership Login control appearance. For example, by using them, you can:
– Display a login link instead of a login button;
– Select the text displayed for the login button;
– Add several hyperlinks to you Login control such a hyperlink to a registration page or a hyperlink to a help page.
The next example presents these approaches:
<asp:Login ID=”Login1″ runat=”server”
BackColor=”aliceblue”
BorderColor=”Black” BorderStyle=”double”
CreateUserText=”Register”
CreateUserUrl=”Register.aspx”
HelpPageText=”Additional Help”
HelpPageUrl=”HelpMe.htm”
InstructionText=”Please enter your user name and password for <br>
logging into the application.”>
<LoginButtonStyle BackColor=”DarkBlue” ForeColor=”White” />
<TextBoxStyle CssClass=”MyLoginTextBoxStyle” />
<TitleTextStyle Font-Italic=”True” Font-Bold=”True” Font-Names=”Arial” />
</asp:Login>
This code displays two additional links—one for a help page and one for a registration page—and adds some short, instructional text below the heading of the Login control.
The next table describes the most important properties for customizing the Login control:
Property | Description |
TitleText | The text displayed as the heading of the control. |
InstructionText | The text that is displayed below the heading of the control. |
FailureText | The text displayed by the Login control if the login attempt was not successful. |
UserNameLabelText | The text displayed as a label in front of the user name text box. |
PasswordLabelText | The text displayed as a label in front of the password text box. |
UserName | Initial value filled into the user name text box. |
UsernameRequiredErrorMessage | Error message displayed if the user has not entered a user name. |
PasswordRequiredErrorMessage | Error message displayed if the user has not entered a password. |
LoginButtonText | The text displayed for the login button. |
LoginButtonType | The login button can be displayed as a:
– Link; – Button; – Image. For this purpose, you have to set this property appropriately. Supported values are Link, Button, and Image. |
LoginButtonImageUrl | If you display the login button as an image, you have to provide a URL to an image that is displayed for the button. |
DestinationPageUrl |
If the login attempt was successful, the Login control redirects the user to this page. This property is empty by default. If empty, it uses the forms authentication infrastructure for redirecting either to the originally requested page or to the defautlUrl configured in web.config for forms authentication. |
DisplayRememberMe | Enables you to show and hide the Remember Me check box. By default this property is set to true. |
FailureAction |
Defines the action the control performs after a login attempt failed. The two valid options are: – Refresh – refreshes just the current page; – RedirectToLoginPage – redirects to the configured login page. You can use it if you use the control anywhere else instead of the login page. |
RememberMeSet |
Defines the default value for the Remember Me check box. By default this option is set to false, which means the check box is not checked by default. |
VisibleWhenLoggedIn |
If set to false, the control automatically hides itself if the user is already logged in. If set to true (default), the Login control is displayed even if the user is already logged in. |
CreateUserUrl |
Defines a hyperlink to a page in the website that allows you to create (register!) a user. Therefore, this is typically used for enabling the user to access a registration page. Typically this page displays the CreateUserWizard control. |
CreateUserText | Defines the text displayed for the CreateUserUrl hyperlink. |
CreateUserIconUrl | Defines a URL to an image displayed together with the text for the CreateUserUrl hyperlink. |
HelpPageUrl | URL for redirecting the user to a help page. |
HelpPageText |
Text displayed for the hyperlink configured in the HelpPageUrl property. |
HelpPageIconUrl |
URL to an icon displayed together with the text for the HelpPageUrl hyperlink. |
PasswordRecoveryUrl |
URL for redirecting the user to a password recovery page. This page is used if the user has forgotten the password. Typically this page displays the PasswordRecovery control. |
PasswordRecoveryText |
The text displayed for the hyperlink configured in PasswordRecoveryUrl. |
PasswordRecoveryIconUrl | Icon displayed together with the text for the PasswordRecoveryUrl. |