編輯

共用方式為


Elements Element (Custom Action)

Applies to: SharePoint 2016 | SharePoint Foundation 2013 | SharePoint Online | SharePoint Server 2013

Top-level element in a Feature manifest file that contains Feature element declarations.

Definition

<Elements Id = "Text">
</Elements>

Elements and attributes

The following sections describe attributes, child elements, and parent elements.

Attributes

Attribute Description
xmlns Required. Identifies the XML namespace. The value must be http://schemas.microsoft.com/sharepoint/.
Id Optional Text. Specifies a unique identifier for the Feature manifest file.

Child elements

Parent elements

None

Example

The following example defines a custom action that adds a button to the Server ribbon.

<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <CustomAction
    Id="Ribbon.Library.Actions.AddAButton"
    Location="CommandUI.Ribbon"
    RegistrationId="101"
    RegistrationType="List"
    Title="Add a Ribbon Button">
    <CommandUIExtension>
      <CommandUIDefinitions>
        <CommandUIDefinition
          Location="Ribbon.Library.Share.Controls._children">
          <Button Id="Ribbon.Library.Share.NewRibbonButton"
            Command="NewRibbonButtonCommand"
            Image16by16="Insert an image URL here."
            Image32by32="Insert an image URL here."
            LabelText="Hello World"
            TemplateAlias="o2" />
        </CommandUIDefinition>
      </CommandUIDefinitions>
      <CommandUIHandlers>
        <CommandUIHandler
          Command="NewRibbonButtonCommand"
          CommandAction="javascript:alert('Hello, world');" />
      </CommandUIHandlers>
    </CommandUIExtension>
  </CustomAction>
</Elements>