共用方式為


Custom Action

Applies to: SharePoint Foundation 2010

A custom action represents a Server ribbon, menu, or link customization that a user can see. Custom actions can be bound to list type, content type, file type, or programmatic identifier (ProgID).

Possible scopes:

  • Farm: Yes

  • Web Application: Yes

  • Site Collection: Yes

  • Web Site: Yes

Defining Custom Actions for the User Interface

The user interface can be modified in multiple locations using custom actions. This includes the Server ribbon and other menus inside of SharePoint Foundation.

Custom Actions for the Server Ribbon

When you use a CustomAction element to add a control to the ribbon, controls such as text boxes and dropdowns are supported. User controls and Web Parts, however, are not supported inside of the ribbon. For more information on the ribbon, see Server Ribbon in SharePoint Foundation.

Custom Actions for Other Menus

To define a custom action for a particular menu, you must identify the menu by setting the location to the appropriate SharePoint Foundation namespace, and by using the ID that SharePoint Foundation uses to identify the specific location.

For example, to add a custom action to the Site Settings page, set the Location attribute of the CustomAction element to Microsoft.SharePoint.SiteSettings and specify a particular area within the page through the GroupId attribute.

See Default Custom Action Locations and IDs for a list of the default custom action IDs and locations that are used in an installation of SharePoint Foundation.

Url Tokens for Custom Actions

SharePoint Foundation supports the following tokens with which to start a relative URL:

~site - Web site (SPWeb) relative link.

~sitecollection - site collection (SPSite) relative link.

In addition, you can use the following tokens within a URL:

{ItemId} - Integer ID that represents the item within a list.

{ItemUrl} - URL of the item being acted upon. Only works for documents in libraries.

{ListId} - GUID that represents the list.

{SiteUrl} - URL of the Web site (SPWeb).

{RecurrenceId} - Recurrence index. This token is not supported for use in the context menus of list items.

See Also

Concepts

How to: Modify the User Interface Using Custom Actions

Custom Action Definition Schema

Server Ribbon in SharePoint Foundation

Default Custom Action Locations and IDs