Steps
- Open Visual Studio in your system.
- Select Console Application template and give as name.
- Add a Microsoft.Client Assembly reference file in right side reference tab in visual studio.
- Replace Program.cs with the source code.
- using System;
- using Microsoft.SharePoint.Client;
-
- namespace Microsoft.SDK.SharePointServices.Samples
- {
- class CreateUserCustomActionList
- {
- static void Main()
- {
- string urlWebsite = "http://gauti.sharepoint.com/sites/gp";
- ClientContext clientContext = new ClientContext(urlWebsite);
- Web oWebsite = clientContext.Web;
-
- List oList = oWebsite.Lists.GetByTitle("TestList");
- UserCustomActionCollection collUserCustomAction = oList.UserCustomActions;
-
- UserCustomAction oUserCustomAction = collUserCustomAction.Add();
- oUserCustomAction.Location = "EditControlBlock";
- oUserCustomAction.Sequence = 100;
- oUserCustomAction.Title = "My First User Custom Action";
- oUserCustomAction.Url = urlWebsite + @"/_layouts/MyPage.aspx";
- oUserCustomAction.Update();
-
- clientContext.Load(oList,
- list => list.UserCustomActions);
-
- clientContext.ExecuteQuery();
- }
- }
- }
Hit F5 and check the output.
Thanks for reading my blogs!!!