大家好:
最近做一个SharePoint项目,对于我这个ASP.Net开发人员来说,刚开始如一头雾水,什么也看不懂。苦忙了一个月将自己做的东西整理下知识点。希望对刚入门的有所帮助。更希望能得到大神的指点。
需要:为文档库管理页面添加一个ribbon,用户点击ribbon是可以模态窗口打开一个新页面。
App开发步骤:
一、打开vs2012,创建SharePoint应用程序。
在创建向导中选择“SharePont托管”、站点写自己站点的URL。
二、实现功能。
选中项目,添加“功能区自定义操作”。用户可以研究现向导,其实只是些XML配置。这里用户可以直接点就行,把下面的代码复制到xml.文件中就可以。
<span style="font-size:18px;"><?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction Id="1861cc39-9995-4d15-870c-0109bcefe57f.RibbonSendMessage"
RegistrationType="List"
RegistrationId="101"
Location="CommandUI.Ribbon"
Sequence="10001"
Title="文档纠错"
HostWebDialog="TRUE"
HostWebDialogHeight="450"
HostWebDialogWidth="550"
>
<CommandUIExtension>
<!--
使用要为自定义操作启用的控件和命令操作
更新下方的 UI 定义。
-->
<CommandUIDefinitions>
<CommandUIDefinition Location="Ribbon.Documents.Manage.Controls._children">
<Button Id="Ribbon.Documents.Manage.RibbonSendMessageButton"
Alt="请求 RibbonSendMessage"
Sequence="100"
Command="Invoke_RibbonSendMessageButtonRequest"
LabelText="文档纠错"
TemplateAlias="o1"
Image32by32="_layouts/15/images/placeholder32x32.png"
Image16by16="_layouts/15/images/placeholder16x16.png" />
</CommandUIDefinition>
</CommandUIDefinitions>
<CommandUIHandlers>
<CommandUIHandler Command="Invoke_RibbonSendMessageButtonRequest"
CommandAction="~appWebUrl/Pages/SendMessage.aspx?{StandardTokens}&SPListItemId={SelectedItemId}&SPListUrlDir={ListUrlDir}&SPListId={ListId}"
EnabledScript="javascript:SP.ListOperation.Selection.getSelectedItems().length == 1;"/>
</CommandUIHandlers>
</CommandUIExtension >
</CustomAction>
</Elements>
</span>
三、这里模态窗口打开的是SendMessage.aspx.需要在这个页面中,在PlaceHolderAdditionalPageHead中添加
<WebPartPages:AllowFraming ID="AllowFraming1" runat="server" />
四、在Feature中,将添加ribbon添加到Feature的右边。 部署在自己的站点下就可以,看到自己实现的功能。