In the TropicalGreen project, open RightMenu.ascx
(created in Chapter 13). Drag and drop a Button onto the Web User Control and give it the following properties:
Property |
Value |
|
|
|
|
In Design
view, double-click on the form to get to its code behind file. Add the Microsoft.ContentManagement.Web.Security
namespace above the namespace declaration:
using Microsoft.ContentManagement.Web.Security;
In the Page_Load()
event handler, add the following code.
//Show Login or Logout button, depending on context if(CmsHttpContext.Current.IsDefaultGuestEnabled) { if(CmsHttpContext.Current.IsLoggedInAsGuest) { btnLogin.Text = "Login"; } else { btnLogin.Text = "Logout"; } } else { btnLogin.Visible = false; }
We will first use the IsDefaultGuestEnabled
property to see if guest access has been enabled for the site. The IsLoggedInAsGuest
property checks to see if the user is logged in. Before the...