Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Adds a new UserCustomAction custom action to the collection.
Namespace:  Microsoft.SharePoint.Client
Assemblies:   Microsoft.SharePoint.Client.Silverlight (in Microsoft.SharePoint.Client.Silverlight.dll);  Microsoft.SharePoint.Client (in Microsoft.SharePoint.Client.dll)
Syntax
'Declaration
<RemoteAttribute> _
Public Function Add As UserCustomAction
'Usage
Dim instance As UserCustomActionCollection
Dim returnValue As UserCustomAction
returnValue = instance.Add()
[RemoteAttribute]
public UserCustomAction Add()
Return Value
Type: Microsoft.SharePoint.Client.UserCustomAction
Returns a UserCustomAction instance representing a new custom action to the collection.
Exceptions
| Exception | Condition | 
|---|---|
| UnauthorizedAccessException | The current user does not have permissions to perform the operation. Error code: -2147024891.  | 
Examples
This code example adds a new menu item to the Site Actions menu of the specified site.
using System;
using Microsoft.SharePoint.Client;
namespace Microsoft.SDK.SharePointFoundation.Samples
{
    class UserCustomActionCollection_AddExample
    {
        static void Main()
        {
            string siteUrl = "http://MyServer/sites/MySiteCollection";
            ClientContext clientContext = new ClientContext(siteUrl);
            Web site = clientContext.Web;
            UserCustomActionCollection collUCA = site.UserCustomActions;
            UserCustomAction newUCA = collUCA.Add();
            newUCA.Location = "Microsoft.SharePoint.StandardMenu";
            newUCA.Group = "SiteActions";
            newUCA.Sequence = 1000;
            newUCA.Title = "New Menu Item";
            newUCA.ImageUrl = "/_layouts/images/myIcon.jpg";
            newUCA.Description = "Menu item added";
            newUCA.Url = "/_layouts/create.aspx";
            newUCA.Update();
            clientContext.ExecuteQuery();
            Console.WriteLine("New menu item added to Site Actions menu.\n\nTo view the new menu item, refresh the page.");
        }
    }
}
See Also
Reference
UserCustomActionCollection Class