按代码将自定义链接添加到SharePoint列表设置页面

时间:2011-10-04 08:32:28

标签: c# sharepoint custom-action

我想从代码中添加自定义链接到SharePoint列表设置页面(listedit.aspx),我已经搜索了web和stackoverflow,并且似乎无法找到任何关于这样做的示例或文档。

有关如何从elements.xml和部署/激活执行此操作的示例,但我想从C#代码执行此操作,如下所示:

SPUserCustomAction customAction = spCustomList.UserCustomActions.Add();
customAction.Url = "someurlhere";
customAction.Name = "CustomName";
customAction.Location = "Microsoft.SharePoint.ListSettings";
customAction.Title = "Custom Settings";
customAction.Update();
spCustomList.Update();

亲切的问候

1 个答案:

答案 0 :(得分:3)

您走在正确的轨道上,但您的位置不正确,您需要一个小组。

尝试以下方法:

SPUserCustomAction customAction = spCustomList.UserCustomActions.Add();
customAction.Url = "someurlhere";
customAction.Name = "CustomName";
customAction.Location = "Microsoft.SharePoint.ListEdit";
customAction.Group = "GeneralSettings";
customAction.Title = "Custom Settings";
customAction.Update();

有关地点的详细信息,请参阅Default Custom Action Locations and IDs