In this article, I am going to show you how to add a new menu item into the Site Actions menu.
In order to do that, you must use a Custom Action.
Here is example of Custom Action:
This Custom Action adds a new item menu called “Hello World Application Page”. When a user clicks on this menu item, he is redirected to a /LitWare/ApplicationPage1.aspx
Something that I would like to point out, is the Sequence property. It’s supposed to allow the developer to choose where he wants to put the menu item. It does make that but only among your custom menu items. So you get to set the order of your menu items, those will be appended at the end of the menu. You can try to set it at 1, it will be still added at the end.
What I am going to show you, it’s to actually work around this limitation and explain how you can actually add a new menu item wherever you want to.
This technique will use two different properties : ControlClass and ControlAssembly
In ControlClass we will define the control which needs to be rendered when the menu item get displayed while ControlAssembly defines the assembly which contains this class.
Check out the following sample:
The Code of the Class, note that the class inherits from WebControl (System.Web)
As you can see, I even didn’t provide any sequence in my Custom Action, the important thing here is the MenuGroupId.
It refers in this case to already existing locations that you can find in the v4.master
By setting a MenuGroupId and a Sequence, you can add your Custom Action within the existing menu and not only at the end.