5

I would like to add a custom link to a SharePoint list settings page (listedit.aspx) from code, I have searched the web and Stack Overflow, and can't seem to find any examples or documentation on doing this specifically.

There are a dozen examples on how to do this from the elements.xml and on deployment/activation, but I would like to do this from C# code, like this:

SPUserCustomAction customAction = spCustomList.UserCustomActions.Add();
customAction.Url = "someurlhere";
customAction.Name = "CustomName";
customAction.Location = "Microsoft.SharePoint.ListSettings";
customAction.Title = "Custom Settings";
customAction.Update();
spCustomList.Update();
Jason Aller
  • 3,541
  • 28
  • 38
  • 38
user80130
  • 53
  • 1
  • 6

1 Answers1

4

You are on the right track, but your Location is incorrect and you need a Group.

Try the following:

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();

For more information on Locations, see Default Custom Action Locations and IDs.

Rich Bennema
  • 10,295
  • 4
  • 37
  • 58