Original article: http://msdn2.microsoft.com/en-us/library/bb418731.aspx
In Sharepoint, we can create a feature containing the femaction element to add a custom operation menu item (Entry Control Block item) to the list item or document ). You can add custom commands to the default SharePoint user interface. These menu commands allow users to perform specific operations on list items or documents. For example, you can add an item in the list item or Document menu to redirect users to our custom application page. In this way, we can create a commercial solution that closely integrates the operation menus for Sharepoint list items or documents.
First, create a custom feature. We can define feature in any range, but usually in the website set or scope. The following example defines the feature of a website set range (scope = "Site") and references another caml file, elements. xml.
<Feature
AA929AFF-4602-4d7f-A501-B80AC9A4BB52"
Title = "a sample feature: item auditing"
Description = "a sample feature with an entry control block menu item"
Scope = "Site"
Xmlns = "http://schemas.microsoft.com/sharepoint/">
<Elementmanifests>
<Elementmanifest location = "elements. xml"/>
</Elementmanifests>
</Feature>
Define a custom action
We use the customaction element to define various menu items and links in the SharePoint interface. The following customaction element adds a custom menu item for the document entries in the document library. This is achieved by specifying the registrationtype attribute as list and the registrationid attribute as 101. This is the default document library type ID in Sharepoint. <Customaction
Id = "itemauditing. ecbitemmenu"
Registrationtype = "list"
Registrationid = "101"
Imageurl = "/_ layouts/images/gortl. GIF"
Location = "editcontrolblock"
Sequence = "300"
Title = "view audit history">
<Urlaction
Url = "~ Site/_ layouts/itemaudit. aspx
? Itemid = {Itemid} & amp; listid = {listid} "/>
</Customaction>
After creating the customaction element, you must add a urlaction element inside it, including a URL attribute. To redirect a user to an application page (such as itemaudit. aspx), we also need to consider whether the application page is running in the current website context environment or in the current website collection environment. In the following example, a dynamic tag is added before the URL ~ Site, at runtime ,~ The site is replaced with the URL of the current website.
~ Site/_ layouts/itemaudit. aspx
When we redirect users to a custom application page through the customized list item operation menu, we also need to pass the query string to the application page, this allows you to obtain splist and splistitem objects through programming. SharePoint supports two other dynamic tags: {listid} and {Itemid }. SharePoint replaces the guid and ID of the list items with the list or document library.
~ Site/_ layouts/itemaudit. aspx? Itemid = {Itemid} & amp; listid = {listid}
This method allows the background to customize application pages (such as itemaudit. aspx) Get the listid and Itemid values during page initialization. You can program the list items or documents to implement the expected automated tasks.
View Video