To add a custom item to the right-click menu in EPiServer you can use the ContextMenu.CreateMenuItem method.

In the following sample the code first checks that the current user has edit access to the site.

The parameters to the method are:

  1. caption - The name shown in the menu.
  2. url - An optional link to a page that the browser will be redirected to when the item is clicked.
  3. javaScript - an optional string containing a script to be executed when the item is clicked.
  4. active - a string indicating whether the item should be enabled or not.
  5. imageUrl - An optional name of an image to be shown in the menu. The root path to the image will be the App_Themes catalog.
  6. RightClickMode - In which mode will the item be shown.
if (!CurrentPage.ACL.QueryDistinctAccess(EPiServer.Security.AccessLevel.Edit))
RightClickMenuItem item =
    ContextMenu.CreateMenuItem("Added Item",
ContextMenu.Menu.Add("Added Item", item);

To remove an item, call the following method:

ContextMenu.Menu.Items.Remove("Name of Item");

It is also possible to remove standard EPiServer Menu Items by calling the Remove method with the name of the built-in Item as parameter. These are some of the built-in EPiServer Items that can be removed: