Prevent the CMSPortalManager control from rendering JavaScript libraries

Kentico’s core jQuery libraries are loaded once a user is authenticated, since they are used by the CMS Desk.  In some cases, this may inadvertently break the functionality of your custom JS. The following is a workaround to prevent the CMSPortalManager control from rendering the default JavaScript libraries when a user is authenticated, but not when a user enters into the CMS desk.
As you can see in our Developers Guide: Creating ASPX master pages the ajaxToolkit:ToolkitScriptManager - allows pages to use AJAX components. This is required by all pages that contain the CMSPortalManager control.

Here is a small workaround to dynamically decide when the PortalManager control is used, based on the current viewmode.  In this example the CMSPageManager control will be used in all viewmodes except the LiveSite view mode, and the CMSPortalManager control will be used in the LiveSite.
if (CMSContext.ViewMode != CMS.PortalEngine.ViewModeEnum.LiveSite) { var portalManager = new CMS.PortalControls.CMSPortalManager(); portalManager.EnableViewState = false; portalManager.ID = "manPortalEdit"; plcManagers.Controls.Add(portalManager); }

Special thanks go to Henry Tait.

See also: Creating ASPX master pages, How to register and use the native Kentico jQuery library

Applies to: Kentico Version 7.x
Share this article on   LinkedIn Google+

Martin Danko

Let me guide you on your journey of success. I will show you how to optimize your content production with Kentico Draft. Check out