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
Delete A List Item In SharePoint Using CSOM (Announcement List)
WhatsApp
Gowtham Rajamanickam
8y
24.2
k
0
0
25
Blog
In this blog, I will add a code snippet for deleting an item in a SharePoint announcement list using client object model.
The client object model must conclude with a call to ExecuteQuery() or ExecuteQueryAsync(ClientRequestSucceededEventHandler, ClientRequestFailedEventHandler).
Steps
Open Visual Studio in your system.
Select Console Application template and give it a name.
Add a Microsoft.Client Assembly reference file in the right side Reference tab in Visual Studio.
Replace Program.cs with the source code below.
Code snippet
using
System;
using
Microsoft.SharePoint.Client;
namespace
GowthamArticles
{
class
CreateListItem
{
static
void
Main()
{
ClientContext clientContext =
new
ClientContext(
"https://gowtham.sharepoint.com/tutorials"
);
List oList = clientContext.Web.Lists.GetByTitle(
"Announcements"
);
ListItem oListItem = oList.Items.GetById(7);
oListItem[
"Title"
] =
"Custom Title updated Programmatically."
;
oListItem.DeleteObject();
clientContext.ExecuteQuery();
}
}
}
Thanks for reading.
SharePoint
CSOM
Recommended related topics
Membership not found