Export (0) Print
Expand All
1 out of 14 rated this helpful - Rate this topic

How to: Add a Login Button to an ASP.NET Web Page 

To allow users to log in to an ASP.NET application that uses ASP.NET membership (forms authentication) for user authentication, you can use the LoginStatus control. The LoginStatus control detects a user's authentication status. If a user is not authenticated, the control displays a button that directs the user to the application's login page. If the user is authenticated, the LoginStatus control displays a button that users can click to log out of the application.


By default, ASP.NET membership and forms authentication is configured to work with a page named Login.aspx. You can change the default login page name in the application's configuration file by setting the loginUrl attribute of the <forms> element.

By default, the LoginStatus control renders a button. You can configure the button text by setting the LoginText property. Alternatively, you can configure the LoginStatus control to display an image (an ImageButton control).

To add a login button to an ASP.NET Web page

  1. Add a LoginStatus control to your page.

  2. Customize the text displayed in the button by setting the LoginText and LogoutText properties.

To add a login or logout images

  1. Add a LoginStatus control to your page.

  2. Set the LoginImageUrl and LogoutImageUrl to the URL of the image to display as login and logout images, respectively.

  3. Optionally customize the alt text displayed for the image by setting the LoginText and LogoutText properties.

See Also

Other Resources

Login ASP.NET Controls

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

© 2014 Microsoft. All rights reserved.