Sunday, August 11, 2013

Custom item menu action in document Library

1 comment
Many times we need additional functionality to List and Library. To fill this gap we add webpart to the listview page, add ribbon item or add custom action to the item menu. Here i will show you how to add custom action to document library item menu.

Scenario : Add custom action name  "Custom Action" in Item menu in document library.


We can add custom action using Empty Element. Add Empty Element to the existing project.

Click  Element.xml. Add following text to it.

<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <CustomAction Id="MyCustomAction"
    RegistrationType="List"
    RegistrationId="101"
    Location="EditControlBlock"
    Sequence="10001"              
    Title="Custom Action">
    <UrlAction Url="javascript:alert('Hello world')"></UrlAction>/>
  </CustomAction>
</Elements>

Id: Custom Action id.
RegistrationType: Where you want to attach per item. Possible values are None, List, ContentType, ProgId, FileType

RegistrationId: Identifier for the list.  In our case it is document library so "101"
Location:  Location for the custom action
Sequence: Order for the priority for action
Title: Title for the action
UrlAction: Specify action for page.

Deploy solution and go to document library to verify solution.

It should look like this



More more information on custom action check this reference article
http://msdn.microsoft.com/en-us/library/sharepoint/ms460194.aspx



1 comments:

Anonymous said...

Thank YOU!