C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
How to Add a User Custom Action for List Items
WhatsApp
Gowtham Rajamanickam
10y
8.9
k
0
0
25
Blog
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!!!
SharePoint 2013
custom action
Net Client Side Object Model
Recommended related topics
Membership not found