Home > Deveploment and Programming, SharePoint Development > Create custom context menu in Sharepoint Document Library

Create custom context menu in Sharepoint Document Library

There are two very simple technique to create context menu in SharePoint 2010.

Approach1 .

This approach will use feature to create and deploy the context menu in document library.

Drawback: Once feature will be activated, the context menu will be available in all document library.

 

Step1.

Create an feature file as below named Feature.xml.

<?xml version=”1.0″ encoding=”utf-8″ ?>

<Feature xmlns=”http://schemas.microsoft.com/sharepoint/

Id=”{AA108E80-DA4A-4757-B87E-6EC4DF3E8487}”

Scope=”Web”

Title=”Open as Word 2003″

Version=”1.0.0.0″

Description=”Displays Open as Word 2003 link in context menu of a document library.”>

<ElementManifests>

<ElementManifest Location=”MenuItems.xml”/>

</ElementManifests>

</Feature>

Step2.

Create an menufest file as below named MenuItems.xml which contain the behavior of menu.

<?xml version=”1.0″ encoding=”utf-8″ ?>

<Elements xmlns=”http://schemas.microsoft.com/sharepoint/“>

<CustomAction

Id=”{843AEE73-B596-42b8-83FD-104C771E658B}”

RegistrationType=”List”

ShowInLists = “True”

RegistrationId=”101″

Location=”EditControlBlock”

Sequence=”101″

Title=”Move To”>

<UrlAction Url=”~site/SitePages/Home.aspx?ID={ItemId}&amp;List={ListId}”/>

</CustomAction>

</Elements>

 

Step3.

Create a page in page library for redirection and replace the path in the MenuItems.xml file as you can see in the bold on.

Step4.

Final work, install and activate the feature.

Create a folder in the 12 hives under Features folder named CustomMenu, and paste the both file (Feature.xml, MenuItems.xml) in the CustomMenu folder.

And now execute the below command, that’s all.

stsadm -o installfeature -name CustomMenu

stsadm -o activatefeature -name CustomMenu -url  “your site url”

Approach 2.

Custom context menu can also be created by SharePoint Designer 2010.

you can visit on the below site.

http://gvaro.wordpress.com/2009/12/19/adding-custom-actions-to-the-list-item-menu-in-sharepoint-2010-using-sharepoint-designer-2010/

Advertisements
  1. Geetha
    24/05/2012 at 11:18 pm

    Hi sanjiv,

    Thanks for the clearcut explanation. I tried to add context menu to my documetn library using the same. But i could not able to see the newly added menu in context menu.
    kindly correct me whr im wrong. btw im using Moss 2007

    i have created the welcome page, and also installed and activated the feature, i can see the feature status as activated in site features section.

    • 25/05/2012 at 4:34 pm

      Hi Geetha,

      It looks, feature has not been installed and activated in the site, you should see the feature in site feature list.

      Cheers
      Sanjiv

  2. 24/09/2014 at 9:08 am

    Those are 30 long years ago…

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

%d bloggers like this: