How to: Use Advanced Features of the ASP.NET Login Control

JavaScript Editor jscript editor     Web designer 



Main Page

You can customize the user interface (UI) text and the appearance (fonts and colors) of the Login control. Alternatively, you can change the overall appearance of the Login control by applying an ASP.NET theme or skin.

Additionally, you can make use of more advanced capabilities of the Login control, such as whether the login information is stored in a persistent cookie in the browser or whether the login control is visible (on pages other than the default login page) when a user is logged in.

To control whether the login control is visible when a user is logged in

  1. Place a Login control on a page.

    NoteNote

    By default, the control is configured to work with a login page named Login.aspx. You can change the name of the login page in the Web.config file by setting the LoginUrl property of the FormsAuthentication class.

  2. If you want the Login control to appear only when a user is not logged in (the control will always be displayed on the login page identified by the LoginUrl property), set the VisibleWhenLoggedIn property to false.

To control whether the authentication token is stored in a persistent cookie

  1. If you want the control to display a Remember me next time check box, set the DisplayRememberMe property to true. If a user selects the Remember me next time check box when he or she logs in, the authentication token will be stored in a persistent cookie in the browser.

  2. If you want the Remember me next time check box to be selected by default, set the RememberMeSet property to true.

  3. If you want the authentication token to be stored in a persistent cookie without giving the user the option to clear the Remember me next time check box, set the RememberMeSet property to true and set the DisplayRememberMe property to false. This is not recommended for sites that can be accessed from public computers that serve multiple users, as a user's persistent authentication token could be used by an unwanted user.

To add help links to the Login control

  1. To add a link to the Login control that takes the user to a URL where he or she can create a new user account, set the CreateUserText property to text such as Click here to register and the CreateUserUrl property to the URL of the Help page, such as ~/register.aspx.

  2. To add a link to the Login control that takes the user to a URL for users to recover their passwords, set the PasswordRecoveryText property to text such as Forgot your password? and the PasswordRecoveryUrl property to the URL of the Help page, such as ~/recoverpassword.aspx.

  3. To add a link to the Login control that takes the user to a Help URL, set the HelpPageText property to text such as Need Help? and the HelpPageUrl property to the URL of the help page, such as ~/userhelp.aspx.

To add images to the Login control

  • To use an image instead of a Log In button, set the LoginButtonImageUrl property to the URL of your login image file, such as ~/images/login.gif.

    You can also include images with the links to the create user URL, password recovery URL, and Help URL using the PasswordRecoveryIconUrl, CreateUserIconUrl, and HelpPageIconUrl properties, respectively.

See Also



JavaScript Editor jscript editor     Web designer