Sunday, October 14, 2012

Delete SharePoint List using SharePoint 2013 client object model




In this blog we will discuss how to delete a SharePoint list using SharePoint 2013 client object model. In my previous article I have discussed about working with client object model in SharePoint 2013.

As discussed in the last article also, to work with SharePoint 2013 client object model we need Microsoft.SharePoint.Client.Runtime.dll and Microsoft.SharePoint.Client.dll which are located in C:

\ProgramFiles\Common Files\Microsoft Shared\web server extensions\15\ISAPI

Below is the full code:

string siteURL = "http://Your Site URL/";

ClientContext context = new ClientContext(siteURL);

Web web = context.Web;

List list = web.Lists.GetByTitle("List Name");

list.DeleteObject();

context.ExecuteQuery();

ExecuteQuery() method is very much important, this will execute the query to the server.

Also check some SharePoint 2013 articles on New master pages in SharePoint 2013, Mobile Apps in SharePoint 2013, Audio and Video content type in SharePoint 2013 and Some New features in SharePoint 2013.


0 comments:

Post a Comment

Twitter Delicious Facebook Digg Favorites More