Using the LoginStatus Control


Using the LoginStatus Control

The LoginStatus control displays either a Login link or a Logout link, depending on your authentication status. When you click the Login link, you are transferred to the Login.aspx page. When you click the Logout link, you are logged out of the website.

The page in Listing 20.28 contains a LoginStatus control (see Figure 20.11).

Figure 20.11. Displaying a Login link with the LoginStatus control.


Listing 20.28. ShowLoginStatus.aspx

<%@ Page Language="VB" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head  runat="server">     <title>Show LoginStatus</title> </head> <body>     <form  runat="server">     <div>     <asp:LoginStatus                  Runat="server" />     <hr />     Additional information is available to registered users. Log in to view     the additional information.     </div>     </form> </body> </html> 

After you open the page in Listing 20.28, if you click the Login link, you are redirected to the Login page. If you enter a valid username and password, you are redirected back to the ShowLoginStatus.aspx page.

The LoginStatus control supports the following properties:

  • LoginImageUrl Enables you to specify an image for the Login link.

  • LoginText Enables you to specify the text for the Login link.

  • LogoutAction Enables you to control what happens when the Logout link is clicked. Possible values are Redirect, RedirectToLoginPage, and Refresh.

  • LogoutImageUrl Enables you to specify an image for the Logout link.

  • LogoutPageUrl Enables you to specify a page to which the user is redirected when the user logs out. This property is ignored unless the LogoutAction property is set to the value Redirect.

  • LogoutText Enables you to specify the text for the Logout link.

The LoginStatus control also supports the following two events:

  • LoggingOut Raised before the user is logged out.

  • LoggedOut Raised after the user is logged out.




ASP. NET 2.0 Unleashed
ASP.NET 2.0 Unleashed
ISBN: 0672328232
EAN: 2147483647
Year: 2006
Pages: 276

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net