CustomAction Element (Custom Action)
Defines a single custom action for a link or toolbar item.
<CustomAction ContentTypeId = "Text" ControlAssembly = "Text" ControlClass = "Text" ControlSrc = "Text" Description = "Text" GroupId = "Text" Id = "Text" ImageUrl = "Text" Location = "Text" RegistrationId = "Text" RegistrationType = "Text" RequireSiteAdministrator = "TRUE" | "FALSE" Rights = "Text" Sequence = "Integer" ShowInLists = "TRUE" | "FALSE" ShowInReadOnlyContentTypes = "TRUE" | "FALSE" ShowInSealedContentTypes = "TRUE" | "FALSE" Title = "Text"> </CustomAction>
| Attribute | Description |
|---|---|
|
ContentTypeId |
Optional Text. Specifies the ID of a content type to associate with the custom action. |
|
ControlAssembly |
Optional Text. Specifies the assembly of a control that supports the custom action. |
|
ControlClass |
Optional Text. Specifies a control class that supports the custom action. |
|
ControlSrc |
Optional Text. Specifies the relative URL of the .ascx file that serves as the source for the custom action, for example, |
|
Description |
Optional Text. Specifies a longer description for the action that is exposed as a tooltip or sub-description for the action. |
|
GroupId |
Optional Text. Identifies an action group that contains the action, for example, See Default Custom Action Locations and IDs for a list of the default custom action group IDs that are used in Windows SharePoint Services. |
|
Id |
Optional Text. Specifies a unique identifier for the custom action. The ID may be a GUID, or it may be a unique term, for example, |
|
ImageUrl |
Optional Text. Specifies a virtual server relative link to an image that presents an icon for the item. |
|
Location |
Optional Text. Specifies the location of this custom action, for example, If contained within a custom action group, the value of the Location attribute must equal the location of the CustomActionGroup element. See Default Custom Action Locations and IDs for a list of the default custom action locations that are used in Windows SharePoint Services. |
|
RegistrationId |
Optional Text. Specifies the identifier of the list or item content type that this action is associated with, or the file type or programmatic identifier (ProgID). |
|
RegistrationType |
Optional Text. Specifies the registration attachment for a per-item action. Possible values include:
|
|
RequireSiteAdministrator |
Optional Boolean. TRUE to specify that the item be displayed only if the user is a site administrator; otherwise, FALSE. Using the RequireSiteAdministrator attribute for the drop-down menu of Windows SharePoint Services commands associated with list items is not supported. |
|
Rights |
Optional Text. Specifies a set of rights that the user must have in order for the link to be visible, for example, |
|
Sequence |
Optional Integer. Specifies the ordering priority for actions. |
|
ShowInReadOnlyContentTypes |
Optional Boolean. TRUE if the custom action is only displayed for read-only content types on the page for managing content types. The default value is FALSE. |
|
ShowInSealedContentTypes |
Optional Boolean. TRUE if the custom action is only displayed for sealed content types on the page for managing content types. The default value is FALSE. |
|
Title |
Required Text. Specifies the end user description for this action. |
You can use the CustomAction element to add standard ASP.NET controls and user controls (for example, text boxes or option buttons) as custom actions in toolbars. However, you can only add controls instantiating menu items to the drop-down menus of toolbars; you cannot add Web Parts or arbitrary controls.
For an example of how this element is used, see Custom Action Definitions.
I've created 2 custom actions, they are defined as following :
<CustomAction
Id="MyTestActions.MyTestAction1"
RegistrationType="ContentType"
RegistrationId="0x0100af0aa3faf19d41339ad84d787dd93550"
Location="EditFormToolbar"
Title="My Test Action">
<UrlAction Url="javascript:alert('ID={ItemId}&ListID={ListId}');return false;"/>
</CustomAction>
<CustomAction
Id="MyTestActions.MyTestAction2"
RegistrationType="ContentType"
RegistrationId="0x0100af0aa3faf19d41339ad84d787dd93550"
Location="EditControlBlock"
Title="My Test Action">
<UrlAction Url="javascript:alert('ID={ItemId}&ListID={ListId}');return false;"/>
</CustomAction>
The "MyTestAction2" works fine, but the "MyTestAction1" doesn't !! Why?
--------------
Issue fixed : the ContentTypeId (RegistrationId field above) must be in upper case!!
This code works fine :
<CustomAction
Id="MyTestActions.MyTestAction1"
RegistrationType="ContentType"
RegistrationId="0x0100AF0AA3FAF19D41339AD84D787DD93550"
Location="EditFormToolbar"
Title="My Test Action">
<UrlAction Url="javascript:alert('ID={ItemId}&ListID={ListId}');return false;"/>
</CustomAction>
Warning : you also have to write it in upper case while defining the ContentType ; actually, it is recommended that every where you use a ContentTypeId you type it in upper case I think.
Hope it can help!
- 3/17/2010
- tdelville
- 3/23/2010
- tdelville2
I use this sample to add custom control in Toolbar, it does not show any errors, but dhows only MY ECB ITEM as title.
Is it possible to add user control at this menu.
<CustomAction
Id="UserInterfaceLightUp.ECBItemToolbar"
RegistrationType="List"
RegistrationId="101"
ControlClass="System.Web.UI.UserControl"
ControlSrc = "/_controltemplates/myTest.ascx"
Location="EditControlBlock"
Sequence="106"
Title="MY ECB ITEM">
<UrlAction Url="/_layouts/LightupHello.aspx?ECBItem"/>
</CustomAction>
-------
You cannot bring the parameter in UrlAction Url, you should find other way to pass parameter.
- 3/29/2007
- idbi
- 4/22/2009
- Thomas Lee
I need to provide context menu for .eml files in document library in sharepoint 3.0
Does any one know ? pls guide friends...
Code:
<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<!-- Per Item Dropdown (ECB) Type="ECBItem"-->
<CustomAction
Id="EMLViewer.ECBItemToolbar"
RegistrationType="List"
RegistrationId="101"
ContentTypeId
Location="EditControlBlock"
Sequence="106"
ImageUrl="/_layouts/images/ICEML.GIF"
Title="EML Viewer">
<UrlAction Url="/_layouts/EMLViewer.aspx?SITEURL={SITEURL}&ItemId={ItemId}&ListId={ListId}"/>
</CustomAction>
</Elements>
- 3/25/2008
- PrashanthSpark
- 4/18/2009
- Stanley Roark
http://blog.thekid.me.uk/archive/2008/04/29/sharepoint-custom-actions-in-a-list-view-webpart.aspx
Sample CustomActions for SharePoint
http://blog.thekid.me.uk/archive/2007/06/23/sample-editcontrolblock-customaction-for-sharepoint.aspx
- 5/19/2008
- Vince Rothwell
http://johnholliday.net/resources/customactions.html
-Rich
- 5/3/2008
- Rich Finn [TW]
- 12/17/2007
- Michael Bollhoefer_1326429567
The ContentTypeId attribute throws an error when registering a CustomAction element feature via STSADM. Use RegistrationId instead with RegistrationType="ContentType"
<CustomAction
Id="MyTestActions.MyTestAction1"
RegistrationType="ContentType"
RegistrationId="0x0100DD47B0D8BB58458A8D894A16BDC2CA210100D4067570A1B9DB4B83806954FF25AF7D"
Location="EditControlBlock"
Title="My Test Action">
<UrlAction Url="/_layouts/TestAction1.aspx?ID={ItemId}&ListID={ListId}"/>
</CustomAction>
- 9/8/2007
- Thomas Prentis