Home Gitesh Portfolio Blog About Me Gallery Contact

Programmatically detect whether it is CMSDESK or live website mode in Kentico

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,
    }
}

Posted: 22/04/2013 8:50:00 p.m. by Gitesh Shah | with 0 comments