Creating Custom Menu with Sub-Menus under Site Actions in SharePoint

We can add custom menu in site actions with our most accessed URL’s like “Quota Increase”, “Owner change”, etc. like the below screen.

But, Why we need to do this?

  1. Well, It’s a good user friendly addition, they don’t need to search for a link to raise a quota increase or ownership change or etc.
  2. Security trimming – This will avoid incorrect persons raising the request and rejections.
  3. Mistyped URLs – This will avoid  wrong URL’s being entered.  On clicking the link, we can direct them to the request form with auto filled URL’s of the site.
Creating custom menu with sub menus under site actions

Here is the code:

using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI.WebControls;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint;
namespace Crescent.SharePointSupport
	public class SiteActionsMenu : WebControl
		protected override void CreateChildControls()
			SPContext.Current.Site.CatchAccessDeniedException = false;
			//MenuItemTemplate siteCollSettings =
			//GetNewItemTemplate(“Top Level Site Settings”, “/_layouts/settings.aspx”, “/_layouts/images/crtsite.gif”, “Manage site settings for top level site.”);
			//siteCollSettings.Sequence = 399;
			catch (UnauthorizedAccessException)
			// Do nothing}

		private void AddSharePointSupportMenus()
			catch (UnauthorizedAccessException)

			SubMenuTemplate userAndPermissions = GetNewMenuTemplate(“SmartTools.EnhancedSiteActions.UserAndPermissions”, “SharePoint Support”, “Access SharePoint Support Links.”, “/_layouts/images/menuprofile.gif”, 402);
			string url = string.Format(“{0}/_layouts/people.aspx”, SPContext.Current.Web.Url);
			MenuItemTemplate peopleAndGroups = GetNewItemTemplate(“Quota Increase”, url, “/_layouts/images/PPEOPLE.GIF”, “Raise a Request for increasing the site quota.”);
			url = string.Format(“{0}/_layouts/user.aspx”, SPContext.Current.Web.Url);
			MenuItemTemplate advPerm = GetNewItemTemplate(“Ownership Change”, url, “/_layouts/images/menupersonalize.gif”, “Raise a request to change the site owners.”);

			url = string.Format(“{0}/_layouts/user.aspx”, SPContext.Current.Web.Url);
			MenuItemTemplate Deletesite = GetNewItemTemplate(“Request to delete Site”, url, “/_layouts/images/manageuser.gif”, “Raise a request to delete the current site.”);
			url = string.Format(“{0}/_layouts/user.aspx”, SPContext.Current.Web.Url);
			MenuItemTemplate ChangeURL =GetNewItemTemplate(“Request to change Site URL”, url, “/_layouts/images/LISTSET.GIF”, “Raise a request to change the current site’s URL.”);
			url = string.Format(“{0}/_layouts/user.aspx”, SPContext.Current.Web.Url);
			MenuItemTemplate Genquery =GetNewItemTemplate(“General Query to Support”, url, “/_layouts/images/menuprofile.gif”, “Send a question to SharePoint Support.”);
			url = string.Format(“{0}/_layouts/user.aspx”, SPContext.Current.Web.Url);
			MenuItemTemplate FAQLinks =GetNewItemTemplate(“Frequently Asked Questions(FAQ)”, url, “/_layouts/images/NEWSPG.GIF”, “Access Frequently asked questions section”);
			url = string.Format(“{0}/_layouts/user.aspx”, SPContext.Current.Web.Url);
			MenuItemTemplate Learning = GetNewItemTemplate(“SharePoint Learning”, url, “/_layouts/images/Home.gif”, “Access SharePoint Learning section”);

		private static MenuItemTemplate GetNewItemTemplate(string text, string url, string imageUrl, string description)
			MenuItemTemplate item = new MenuItemTemplate();
			item.Text = text;
			item.ClientOnClickNavigateUrl = url;
			item.ImageUrl = imageUrl;
			item.Description = description;
			return item;
		private static SubMenuTemplate GetNewMenuTemplate(string id, string text, string description, string imageUrl, int sequence)
			SubMenuTemplate menuTemplate = new SubMenuTemplate();
			menuTemplate.Text = text;
			menuTemplate.Description = description;
			menuTemplate.ID = id;
			menuTemplate.ImageUrl = imageUrl;
			menuTemplate.Sequence = sequence;
			return menuTemplate;

Don’t forget to add a safe control entry.

Salaudeen Rajack

Salaudeen Rajack - SharePoint Expert with Two decades of SharePoint Experience. Love to Share my knowledge and experience with the SharePoint community, through real-time articles!

Leave a Reply

Your email address will not be published. Required fields are marked *