Freigeben über


UserCustomActionCollection.Add-Methode

Der Auflistung hinzugefügt eine neue benutzerdefinierte Aktion für UserCustomAction .

Namespace:  Microsoft.SharePoint.Client
Assemblys:   Microsoft.SharePoint.Client.Silverlight (in Microsoft.SharePoint.Client.Silverlight.dll);  Microsoft.SharePoint.Client.Phone (in Microsoft.SharePoint.Client.Phone.dll)  Microsoft.SharePoint.Client (in Microsoft.SharePoint.Client.dll)

Syntax

'Declaration
Public Function Add As UserCustomAction
'Usage
Dim instance As UserCustomActionCollection
Dim returnValue As UserCustomAction

returnValue = instance.Add()
public UserCustomAction Add()

Rückgabewert

Typ: Microsoft.SharePoint.Client.UserCustomAction
Gibt eine UserCustomAction -Instanz, die eine neue benutzerdefinierte Aktion der Auflistung darstellt.

Ausnahmen

Ausnahme Bedingung
UnauthorizedAccessException

Der aktuelle Benutzer ist nicht zum Ausführen des Vorgangs berechtigt. Fehlercode:-2147024891.

Beispiele

In diesem Codebeispiel hinzugefügt im Menü Websiteaktionen der angegebenen Website ein neues Menüelement.

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.");
        }
    }
}

Siehe auch

Referenz

UserCustomActionCollection Klasse

UserCustomActionCollection-Member

Microsoft.SharePoint.Client-Namespace