Customizing the administration interface and web application events

  Previous topic Next topic JavaScript is required for the print function Mail us feedback on this topic! Mail us feedback on this topic!  

This chapter describes how to customize the administration interface and website functionality in the way which is safe for future system updates and compatible with the import/export functionality.


Please note that a certain level of user interface customization can be achieved using UI personalization.


System events (Groups)


There are several groups of system events that can be handled by your custom code. There are predefined custom methods that allow you to influence default page cycle of the system pages/controls and customize the administration interface. These classes are located in ~/App_Code/Global/CMS folder.


There are following system events that can be customized:


CMSApplication.cs – Global application events (Start, End, …)
CMSSession.cs – Session events (Start, End, …)
CMSRequest.cs – Request events (Start, End, …)
CMSPageEvents.cs – Page events (Init, Load, …)
CMSUserControlEvents – User control events (Init, Load, …)


These events are fired on standard Application (Session, Request, Page, Control) cycle and provide you with the methods that are fired before and after each of these events.


CMSCustom.cs – Common custom events. Special events that are raised from the system. Binding of these events is initialized within the Init method of this class.


Available methods to customize




BeforeApplicationStart - Fires before the application start event
AfterApplicationStart - Fires after the application start event
BeforeApplicationEnd - Fires before the application end event
AfterApplicationEnd - Fires after the application end event
BeforeApplicationError - Fires before the application error event
AfterApplicationError - Fires after the application error event




BeforeSessionStart - Fires before the session start event
AfterSessionStart - Fires after the session start event
BeforeSessionEnd - Fires before the session end event
AfterSessionEnd - Fires after the session end event




BeforeBeginRequest – Fires before the request start event
AfterBeginRequest – Fires after the request start event
BeforeEndRequest – Fires before the request end event
AfterEndRequest – Fires after the request end event
BeforeAcquireRequestState – Fires before the acquire request state event
AfterAcquireRequestState – Fires after the acquire request state event
BeforeAuthorizeRequest – Fires before the request authorization event
AfterAuthorizeRequest – Fires after the request authorization event
BeforeAuthenticateRequest – Fires before the request authentication event
AfterAuthenticateRequest – Fires after the request authentication event




BeforePagePreInit – Fires before page PreInit event
AfterPagePreInit – Fires after page PreInit event
BeforePageInit – Fires before page Init event
AfterPageInit – Fires after page Init event
BeforePageLoad – Fires before page Load event
AfterPageLoad – Fires after page Load event
BeforePagePreRender – Fires before page PreRender event
AfterPagePreRender – Fires after page PreRender event
BeforePageRender – Fires before page Render event
AfterPageRender - Fires after page Render event




BeforeUserControlInit – Fires before UserControl Init event
AfterUserControlInit – Fires after UserControl Init event
BeforeUserControlLoad – Fires before UserControl Load event
AfterUserControlLoad – Fires after UserControl Load event
BeforeUserControlPreRender – Fires before UserControl PreRender event
AfterUserControlPreRender – Fires after UserControl PreRender event
BeforeUserControlRender – Fires before UserControl Render event
AfterUserControlRender - Fires after UserControl Render event




Following examples just briefly show how to customize the solution with your own functionality. If you need to customize certain page of the interface, you should see the code of the page so the customization matches the page structure.


Using the Page event to add tab (CMSPageEvents.cs) – This custom code will add a new tab to the main page of the E-commerce module:




using CMS.UIControls;

using CMS.Controls;


/// <summary>

/// Fires before page Load

/// </summary>

/// <returns>Returns true if default action should be performed</returns>

public static bool BeforePageLoad(object sender, EventArgs e)


// Add your custom actions

 CMSPage page = (CMSPage)sender;

switch (page.RelativePath.ToLower())


      case "/cmsdesk/tools/ecommerce/header.aspx":

          BasicTabControl tabControl = (BasicTabControl)page["TabControl"];

          // Add tabs

          string[,] tabs = BasicTabControl.GetTabsArray(1);


          tabs[0, 0] = "Google";

          tabs[0, 2] = "";







  // Return true to allow the default Page_Load event

  return true;



Using the Custom event to resolve custom macro (CMSCustom.cs) – This custom code will handle the macro {#CurrentTime#} in all the modules that support custom macros.




/// <summary>

/// Custom macro handler

/// </summary>

/// <param name="sender">Sender (active macro resolver)</param>

/// <param name="expression">Expression to resolve</param>

/// <param name="match">Returns true if the macro matches (was resolved)</param>

public static string ResolveCustomMacro(MacroResolver sender, string expression,

out bool match)


   match = false;

  string result = expression;


  // Add your custom macro evaluation

  switch (expression.ToLower())


      case "currenttime":

           match = true;

           result = DateTime.Now.ToString();




      return result;



Page url: