Share via


Differences Between Managed and JavaScript Object Models

Applies to: SharePoint Foundation 2010

Available in SharePoint Online

You should be aware of the following important differences between the ECMAScript (JavaScript, JScript) and managed client object models.

  • The method signature may be different, as with the ClientContext() constructor (JavaScript: ClientContext(serverRelativeUrl)). In JavaScript this constructor takes a server-relative URL, but the managed version of this constructor takes either a full URL or a Uri.

  • The two object models use different data value types. The JavaScript object model does not have equivalents for all the data value types in the .NET Framework managed object model. JavaScript regards StringCollection as string[]. On the other hand, JavaScript has some values that the .NET Framework does not have, such as NaN, or negative and positive infinity.

  • The JavaScript object model allows Forms authentication, but you cannot specify the authentication mechanism to connect to the server. For information about the managed client object models and Forms authentication, see Authentication in the Managed Client Object Models.

  • When you are creating an item and adding it to an existing collection, further updates cannot be performed with that collection while the query is outstanding. This issue pertains to adding an item to a collection; otherwise, multiple clients can simultaneously read and write to existing items within a collection.

  • As part of general security, you cannot use the JavaScript object model on a page to work with Microsoft SharePoint Foundation 2010 data unless the page contains a form digest control, for example, <SharePoint:FormDigest runat="server"/>.

  • You generally cannot share variables across scopes, so for this reason you cannot use common coding patterns for try/catch/finally statements.

  • A RoleDefinitionBindingCollection object used in creating role assignments does not have object identity. Therefore, if you create a new RoleDefinitionBindingCollection object and then try to use it after creating a role assignment, an error is returned.

  • Some case-insensitive comparisons do not work the same way on the client as they do on the server. Some server-side comparisons use the Web site locale to do a comparison, but the client can only use invariant culture to avoid frequent round trips.  SharePoint Foundation 2010 does not support case-insensitive comparisons if the server is using a Web site locale.

  • Due to the limitations of an asynchronous postback, you may find that inline script is not called when the page is in certain modes, for example, when a Wiki page is in edit mode. In this case, use a ScriptManager control and its RegisterStartupScript() method to register a startup script block for executing your code, instead of using inline script.

See Also

Concepts

Data Retrieval Overview

Authentication in the Managed Client Object Models

Client Object Model Distribution and Deployment

Common Programming Tasks in the Managed Client Object Model

Other Resources

Client Class Library

JavaScript Class Library

Using the SharePoint Foundation 2010 Managed Client Object Model

Client Object Model Resource Center