Here we go again. One of the simplest but kind of hidden functionality is how to determine if the current posting is accessed in live mode or in the edit mode. Microsoft Content Management Server has several modes to display the page out of these three are the most prominent ones i.e. Published , UnPublished and Editing Mode. It is frequently asked that how you can display hint to the authors while they are Creating a new posting or editing an existing one ...One way to accomplish this is to put it in the Description field of the Placeholder definition that is is accessible from MCMS Template Explorer properties in Visual Studio.Net. By accessing the properties window of the currently selected Checked Out template and clicking on the placeholders property.
But this can result in authors forgetting the hint text in the placeholder and also it is only good for a New page since it is going to be over written by the content in case of re edit.
Here is the API call in MCMS to determine the current MODE programatically. Using this you can bind your label controls to display hint text ....
using Microsoft.ContentManagement.WebControls;
///
/// Checks if we are currently in Authoring Mode or Published Mode
///
/// True if we are in Published Mode i.e. the mode for Subscribers
public bool IsInPublishedMode()
{
bool retValue = false;
WebAuthorContextMode Mode = WebAuthorContext.Current.Mode;
if ( Mode == WebAuthorContextMode.PresentationPublished )
{
retValue = true;
}
return retValue;
}
///
/// Checks if we are currently are editing the content
///
/// True if we are editing content otherwise false
public bool IsContentBeingEdited()
{
bool retValue = false;
WebAuthorContextMode Mode = WebAuthorContext.Current.Mode;
// If a new posting is being created or we are editing existing one ...
if (( Mode == WebAuthorContextMode.AuthoringNew ) ||
(Mode == WebAuthorContextMode.AuthoringReedit))
{
retValue = true;
}
return retValue;
}
AuthoringNew The mode that the MCMS page is in when it is used for authoring a new MCMS page.
AuthoringPreview The mode that the MCMS page is in when it is viewed as a Preview launched from one of the authoring modes.
AuthoringReedit The mode that the MCMS 2002 page is in when it is used for authoring an existing MCMS 2002 page.
PresentationPublished The mode that the MCMS 2002 page is in when it is being browsed in Published mode.
PresentationUnpublished The mode that the MCMS 2002 page is in when it is being browsed in Unpublished mode.
PresentationUnpublishedPreview The mode that the MCMS 2002 page is in when it is viewed as a Preview launched from the PresentationUnpublished mode.
TemplatePreview The mode that the MCMS 2002 page is in when it is viewed as a Preview of the underlying Template.
you can use any of the above enumeration values as per your requirement.
For converting the code to Visual Basic.net