Client Object Model in SharePoint 2010 – Part 1

Client Object Model in SharePoint 2010 is one of the developers dream. It enables developers to
access the SharePoint data from client, the code need not to be deployed in to the server.

Client Object Model can be used in the following three ways.

  • .Net CLR
  • Silverlight Object Model
  • JavaScript

.Net CLR Example:

Create the context to the SharePoint site. No traffic/requests will be made to the server until you call the ExecuteQuery()


try

Source Code

{


ClientContext ctx = new
ClientContext(“http://localhost”);


Web site = ctx.Web;

ctx.Load(site);

ctx.ExecuteQuery();

site.Title = “Update from Client Object Model – Win App”;

site.Update();

ctx.ExecuteQuery();


MessageBox.Show(“Update Succeeded”);

}


catch (Exception ex)

{


MessageBox.Show(“Update Failed “ + ex.ToString());

}

1 comment to Client Object Model in SharePoint 2010 – Part 1

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>