Scenario: Show menu item in SharePoint ECB based on a condition e.g when versioning is enabled in the List or Document Library.
- Create a user control under SharePoint ControlTemplates mapped folder.
- Create an elements file and specify the Id as "AdditionalPageHead" and ControlSrc to be the ascx control created in first step as shown:
In the ascx control we need to define Custom_AddListMenuItems(m, ctx) and Custom_AddDocLibMenuItems(m, ctx)
The code above first creates a page Url and appends to it the current item ID and the list name. It then check the verEnabled property of ctx object. If condition evaluates to true it adds an a menu item to ECB menu.