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

use*_*130 5 c# sharepoint custom-action

我想从代码中添加一个指向 SharePoint 列表设置页面 (listedit.aspx) 的自定义链接,我已经搜索了网络和 Stack Overflow,但似乎找不到任何有关具体执行此操作的示例或文档。

关于如何从 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();
Run Code Online (Sandbox Code Playgroud)

Ric*_*ema 4

您的方向是正确的,但您的位置不正确,您需要一个群组。

请尝试以下操作:

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();
Run Code Online (Sandbox Code Playgroud)

有关位置的更多信息,请参阅默认自定义操作位置和 ID