Saturday, October 13, 2012

Working with SharePoint 2013 client object model

In this article we will discuss about SharePoint 2013 client object model.

In my previous articles I have also explained about What's new in Visual Studio 2012 for SharePoint? , Difference between SharePoint 2013 and SharePoint 2010 and Social networking feature in SharePoint 2013.

In this article we will discuss about how we can update web site properties like Title and Description using SharePoint 2013 client object model. Below is the code:
To work with Client object model we need 2 DLLS:

Microsoft.SharePoint.Client.Runtime.dll
Microsoft.SharePoint.Client.dll

In SharePoint 2013 these DLLs will be located at C:\ProgramFiles\Common Files\Microsoft Shared\web server extensions\15\ISAPI

Once you will refer these two dlls, SharePoint 2013 client object model classes will be available to you.

Below is the code to update web site title and description:

ClientContext context = new ClientContext("Your SharePoint Site URL");

Web web = context.Web;

web.Title = "Fewlines4Biju.com";

web.Description = "Fewlines4Biju.com is a SharePoint web site !";

web.Update();

context.ExecuteQuery();

ExecuteQuery() is necessary because that will only update in the server.

No comments:

Post a Comment