Thursday, July 14, 2011

Client Object Model - Part 1

From this post, we are going to start new series for client object model. If you have not gone through previous post Client Object Model which describes you what client object model is all about, I would strongly encourage you to read that first and then come back and continue reading here.

We are going to star with managed client object model. Managed client object model works on the .Net CLR. That means any normal application that runs on the .Net CLR installed platform.

I am going to show you by taking windows application as an example and look into some of the very basic stuff to get the web properties.

First create a windows application project and take a reference of two DLLs that are needed to work with.

They are Microsoft.SharePoint.Client.dll and Microsoft.SharePoint.Client.Runtime.dll and you can find them 14/ISAPI folder.

public void LoadData()
string webUrl = "{site URL}"; //replace this with your site URL

ClientContext context = new ClientContext(webUrl);

Web web = context.Web;



this.lblWebTitle.Text = web.Title;

this.lblWebDescription.Text = web.Description;


private void button1_Click(object sender, EventArgs e)


As you can see there is very little difference between server object model and COM as far as classes are concern. SPWeb becomes Web, SPContext becomes ClientContext.

Do remember one thing, until and unless we call executequery method, nothing happens. As soon as executequery method is invoked, then managed client object model bundles up all requests together and then pass it to the server. There is no network traffic till then.

Overall approach with client object model is you bundle up all requests that you want to query to server (web properties, lists properties etc) and then call them at once by invoking executequery method.

We are going to see more and more examples with different approaches. Next is doing same with the help of Silverlight Client.

No comments:

Share your SharePoint Experiences with us...
As good as the SharePointKings is, we want to make it even better. One of our most valuable sources of input for our Blog Posts comes from ever enthusiastic Visitors/Readers. We welcome every Visitor/Reader to contribute their experiences with SharePoint. It may be in the form of a code stub, snippet, any tips and trick or any crazy thing you have tried with SharePoint.
Send your Articles to with your Profile Summary. We will Post them. The idea is to act as a bridge between you Readers!!!

If anyone would like to have their advertisement posted on this blog, please send us the requirement details to