How to Create Context Menus on Pages Document Library in SharePoint 2013


Sathish Nadarajan
SharePoint MVP
Published On :   02 Apr 2015
Visit Count
Today :  1    Total :   7405
Plan, Migrate, Secure, Report
SharePoint & Office 365 Tool. Simple & Easy to Use. 15-Day Trial!

Sharegate: Kick-Ass Tool
Think Your SharePoint & Office 365 Are Secure ? Find Out Now!


As usual, I met with a new requirement and thought of sharing this to the community. I want to have a Context Menu on the Pages Document Library and on click of it, I need to do some functionality.

The requirement can be understood better with the below Screen shot.

image

Now, let us see how to do that using Visual Studio.

1. Create a Blank SharePoint Project Using Visual Studio.

2. Add an Empty Element.

3. Modify the Element.xml.

 <CustomAction Id="ContextMenus.Demo"
                 RegistrationType="ContentType"
                 RegistrationId="0x0101"
                 Location="EditControlBlock"
                 ImageUrl="/_layouts/IMAGES/workflows.gif"
                 Sequence="601"
                 Title="MyContextMenu"
                 Description="DemoPurpose">
     <UrlAction Url="javascript:DemoFunction();
                function DemoFunction() 
           {
               alert('Test');
           }"></UrlAction>
   </CustomAction>
 

4. That’s it. Rebuild and Deploy. A new Context Menu will be created on the Pages Doc Library.

image

5. That’s it. We have our own context menu and on click of it, we can do whatever we want. But only thing is, we can write some javascripts only. If we want to have some server side code needs to be written, then by using Ajax calls, we can consume the Server Side Web Methods.

Download the Source HERE

Happy Coding.

Sathish Nadarajan.

SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Categories

Migratiin Tools for SharePoint