Creating Context Menu or ECB Menu For Specific Custom List in Sharepoint.

Posted by Manish Kumar | Computer


In Sharepoint, The Context menu in on a List Item called EditControlBlock (Ecb), By which we can create a Custom Action to an item, whether to add, update, delete or whatever we want. Custom menu is displayed with a dropdown menu with a bunch of option, when you hover or click to the right of the field in sharepoint list. You can create your own menu item to this list and can also provide custom code for some action on the list item. Here is the Procedure to create Context Menu : 
 

1.    Go to the specific sharepoint list on which you want to add the context menu.

2.    Go to List Settings -> Advance settings

3.    Select Yes option on “Allow management of content types” radio button.

4.    Click on newly created  Item content type

profile picture

5.    Copy the cype value from browser address bar (From browser URL).

profile picture

6.    Now, Open Visual Studio, Create a blank sharepoint project.

7.    Add an Empty element.

8.    Modify Elements.xml.

9.    Add the Following Code to it.
 

<CustomAction Id="TestContextMenus.Demo"

                 RegistrationType="ContentType"

                 RegistrationId=" 0x010083527508787F724297115C5F8C7D186C"

                 Location="EditControlBlock"

                 ImageUrl="/_layouts/IMAGES/workflows.gif"

                 Sequence="102"

                 Title="MyContextMenu"

                 Description="DemoPurpose">

     <UrlAction Url="javascript:DemoFunction();

                function DemoFunction()

           {

               alert('Test');

           }"></UrlAction>

   </CustomAction>

10.    Paste the ctype value to RegistrationId, and Write “ContentType” in RegistrationType.

profile picture

12.    Now, Rebuild and Deploy the Project, You will see a new context menu…

profile picture

 

 



user

manisha | April 25, 2017

Thanks a Lot for this usefull information.

1   Reply