Delete the user custom action from ECB using Client Object Model


using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
using
Microsoft.SharePoint;
using
Microsoft.SharePoint.Client;
namespace
ClientObjectModel
{
class Program
{
static void Main(string[] args)
{

//Delete the user custom action from ECB using Client Object Model

string siteURL = "http://serverName:1111/sites/SPSiteDataQuery/";
ClientContext context = new ClientContext(siteURL);
List list = context.Web.Lists.GetByTitle("Shared documents");
UserCustomActionCollection collUserCustomAction = list.UserCustomActions;
context.Load(collUserCustomAction);
context.ExecuteQuery();
foreach (UserCustomAction userCustomAction in collUserCustomAction)
{
if (userCustomAction.Title.ToString() == "Custom Action")
{
userCustomAction.DeleteObject();
context.Load(userCustomAction);
context.ExecuteQuery();
}
}
}
}
}