Client Object Model (OM)

Table of Contents

Available for:

  • .NET CLR
  • Silverlight
  • JavaScript

Semantics of code is designed to be as close as possible for each runtime.

.NET CLR

Requires adding references Microsoft.SharePoint.Client and Microsoft.SharePoint.Client.Runtime.

Unable to find source-code formatter for language: csharp. Available languages are: actionscript, html, java, javascript, none, sql, xhtml, xml
ClientContext clientCtx = new ClientContext("http://moss");
Web site = clientCtx.Web;
clientCtx.Load(site);
clientCtx.ExecuteQuery();
site.Title += "updated by Client OM";
site.Update();
clientCtx.ExecuteQuery();

JavaScript

Unable to find source-code formatter for language: js. Available languages are: actionscript, html, java, javascript, none, sql, xhtml, xml
<script language="javascript" type="text/javascript">
  _spBodyOnLoadFunctionNames.push("Initialize");
  var site;
  var context;
  fuction Initialize()
  {
    context = SP.ClientContext.get_current();
    site = context.get_web();
    context.load(site, "Title");
    context.executeQueryAsync(Succeeded, Failed);
  }
  function Succeeded(sender, args)
  {
    site.set_title(site.get_title() + 'from js');
    site.update();
    context.executeQueryAsync(Succeeded2, Failed);
  }
  function Failed(sender, args)
  {
    alert('request failed ' + args.get_message() + '\n' + args.get_stackTrace());
  }
</script>

External References

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.

Creative Commons License
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License.