Book Image

Building Websites with Microsoft Content Management Server

Book Image

Building Websites with Microsoft Content Management Server

Overview of this book

Microsoft Content Management Server 2002 is a dynamic web publishing system with which you can build websites quickly and cost-efficiently. MCMS provides the administration, authoring, and data management functionality, and you provide the website interface, logic, and workflow. Once your website is up and running, your content contributors can add and edit content on their own, without the need to work with developers or the IT department. First time developers of Microsoft Content Management Server 2002 face a relatively steep learning curve. Not only are they expected to be conversant in the Microsoft .NET Framework, they are also required to be familiar with the concepts of MCMS 2002. Many beginners to MCMS start out by looking at the example site that ships with the product; tweaking it, dissecting it and turning it inside out using the obscure code comments as markers. However, when it comes to starting their own website from scratch, many are baffled ? where do they begin? This book exists to answer that question; teaching the essential concepts of MCMS 2002 in a clear, straightforward and practical manner. Containing answers to some of the most asked questions in developer newsgroups, this book is a treasure trove of tricks and tips for solving the problems faced by MCMS developers. This is a unique resource focused exclusively on the needs of developers using MCMS. It doesn?t waste time and pages on user or administrator level information that is well covered in other documentation. It?s a distillation of practical experience that developers need to get results, fast. The authors carefully structured example project complements and extends the knowledge gained from an initial look at the examples that ship with MCMS.
Table of Contents (28 chapters)
Building Websites with Microsoft Content Management Server
Credits
About the Authors
Introduction

Creating a Login/Logout Button for Authors


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

ID

btnLogin

Text

Login

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...