Export (0) Print
Expand All
Expand Minimize
1 out of 22 rated this helpful - Rate this topic

Creating a Feature for an Entry Control Block Item in Windows SharePoint Services 3.0

Windows SharePoint Services 3
Visual How To

Applies to:  Microsoft Windows SharePoint Services 3.0, Microsoft Office SharePoint Server 2007, Microsoft Visual Studio 2005

Ted Pattison, Ted Pattison Group

May 2007

Overview

You can add a custom menu item for an entry control block to a list item or a document in Microsoft Windows SharePoint Services 3.0 by creating a Feature with a CustomAction element. In this way, you can add custom commands to the default SharePoint user interface. These menu commands allow users to perform custom operations on items and documents. For example, you can create a custom menu item for an entry control block for a list item or document that redirects the user to a custom application page. Use this as a starting point to create business solutions that provide an intuitive user interface to automate domain-specific tasks on list items and documents.

Code It

First, create a custom Feature. You can define the Feature at any scope, but typically it is defined at either the site-collection scope level or site scope level. The following Feature is defined at the level of a site-collection scope (that is, Scope="Site") and includes a reference to another CAML file named elements.xml.

<Feature 
  Id="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>

Defining a Custom Action

Use the CustomAction element to define various types of menu items and links within the default SharePoint user interface. The following CustomAction element adds a custom menu item to the entry control block menu for any document within all document libraries. This is accomplished by specifying the RegistrationType attribute of a List element and a RegistrationId value of 101. This is the type identifier for the default SharePoint document library type.

<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>

Read It

When you create a CustomAction element, you must add an inner UrlAction element that contains a Url attribute. When you redirect the user to an application page, such as ItemAudit.aspx, you must consider whether you want the application page to run inside the context of the current site or the current site collection. In the following example, the dynamic token ~site is added to the beginning of the URL. When Windows SharePoint Services parses this CustomAction element and creates the menu item, it replaces ~site with the URL of the current site.

~site/_layouts/ItemAudit.aspx

When you redirect the user to a custom application page from a menu item for the entry control block of a list item or document, you must typically pass query strings to the custom application page so that it programmatically creates the associated SPList object and SPListItem object. Windows SharePoint Services supports two other dynamic tokens: {ListId} and {ItemId}. Windows SharePoint Services replaces these tokens with the GUIDs that identify the list or the document library, and the integer identifier for the item or the document.

~site/_layouts/ItemAudit.aspx?ItemId={ItemId}&amp;ListId={ListId}

This approach allows a custom application page, such as ItemAudit.aspx, to retrieve the ListId and the ItemId values during its initialization so that it can program against and automate tasks for the item or document that the user is interested in.

See It

WSS3 Creating A Feature For An ECB Item splash

Watch the Video

Length: 4:11 | Size: 7.00 MB | Type: WMV

Explore It

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.