Elements 元素(自定义操作)

适用于:SharePoint 2016 |SharePoint Foundation 2013 |SharePoint Online |SharePoint Server 2013

包含功能元素声明的功能清单文件中的顶级元素。

定义

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

元素和属性

下面各部分介绍了属性、子元素和父元素。

Attributes

属性 说明
xmlns 必填。 标识 XML 命名空间。 该值必须为 http://schemas.microsoft.com/sharepoint/
Id 可选属性,类型为 Text。 指定功能清单文件的唯一标识符。

子元素

父元素

示例

以下示例定义一个自定义操作,该操作将按钮添加到服务器功能区。

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