Examples:
if (CMSContext.ViewMode== CMS.PortalEngine.ViewModeEnum.LiveSite) // Shows only inLiveSite mode
if (CMSContext.ViewMode == CMS.PortalEngine.ViewModeEnum.Preview) // Shows only Preview mode
Complete list of enumeration of viewstates you can use (Note: this list is given by kentico):
namespace CMS.PortalEngine
{
// Summary:
// Page mode enumeration
public enumViewModeEnum
{
// Summary:
// Live site mode
LiveSite = 0,
//
// Summary:
// Preview mode
Preview = 2,
//
// Summary:
// Edit mode - content editing
Edit = 3,
//
// Summary:
// Edit mode - content editing (editing disabled)
EditDisabled = 4,
//
// Summary:
// Edit mode - not current page
EditNotCurrent = 5,
//
// Summary:
// Edit mode with disabled controls - when not authorized or cannot edit
Design = 6,
//
// Summary:
// Design mode with disabled controls - for portal engine pages
DesignDisabled = 7,
//
// Summary:
// Edit form mode - for portal engine pages
EditForm = 8,
//
// Summary:
// Unknown / does not matter
Unknown = 9,
//
// Summary:
// Properties tab
Properties = 10,
//
// Summary:
// Product tab
Product = 11,
//
// Summary:
// User widgets mode
UserWidgets = 12,
//
// Summary:
// User widgets mode with disabled functionality (for preview mode)
UserWidgetsDisabled = 13,
//
// Summary:
// Group widgets mode
GroupWidgets = 14,
}
}