SharePoint CEB自定义操作不会显示从Visual Studio部署的文档库

时间:2014-04-30 11:10:11

标签: sharepoint sharepoint-2010 sharepoint-2013

我遇到从Visual Studio 2012到SharePoint 2013部署的自定义列表(文档库类型)的问题。我的自定义操作未显示此类列表。这是我的自定义操作

SPUserCustomAction action1 = web.UserCustomActions.Add();
action1.RegistrationType = SPUserCustomActionRegistrationType.List;
action1.ImageUrl = "~sitecollection/myresources/Images/Logo16x16.png";
action1.RegistrationId = "101";
action1.Location = "EditControlBlock";                            
action1.Sequence = 500;
action1.Title = "Redirect to my page";
action1.Url = "javascript:__doPostBack('RedirectPostBack','{ItemId}|{ListId}');";
action1.Update();

此代码适用于现有文档库,我可以看到现有列表的新上下文菜单项和从SharePoint网页创建的新自定义列表。

enter image description here

问题是当我尝试从Visual Studio创建和部署新文档库时。在此类文档库的上下文菜单中看不到自定义操作。我使用默认设置。这是我在Visual Studio 2012中创建的自定义文档库

<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
    <!-- Do not change the value of the Name attribute below. If it does not match the folder name of the List project item, an error will occur when the project is run. -->
    <ListTemplate
        Name="Space Check"
        Type="10000"
        BaseType="1"
        OnQuickLaunch="TRUE"
        SecurityBits="11"
        Sequence="110"
        DisplayName="Space Check"
        Description="My List Definition"
        Image="/_layouts/15/images/itdl.png"
        DocumentTemplate="121"/>
</Elements>

有什么想法吗?感谢。

1 个答案:

答案 0 :(得分:1)

要使自定义操作显示在自定义列表定义中,您需要将RegistrationId属性更改为列表定义的Type属性值。在您的情况下,它应该是RegistrationId=10000

如果要将自定义操作附加到所有文档库,可以尝试将其附加到文档内容类型:

SPUserCustomAction action1 = web.UserCustomActions.Add();
action1.RegistrationType = SPUserCustomActionRegistrationType.ContentType;
action1.ImageUrl = "~sitecollection/myresources/Images/Logo16x16.png";
action1.RegistrationId = "0x0101";
action1.Location = "EditControlBlock";                            
action1.Sequence = 500;
action1.Title = "Redirect to my page";
action1.Url = "javascript:__doPostBack('RedirectPostBack','{ItemId}|{ListId}');";
action1.Update();