Client-side development
Client-side development can be leveraged to provide rich, dynamic content and experiences. With Client-side development all of the code runs from the client which in most cases is the end user's web browser. The code is written in a scripting language like JavaScript, ECMAScript, or in the case of Silverlight, using XOML and references script libraries instead of server based objects.
There are two common options for interacting with SharePoint from client-side solutions; the Client Object Model and jQuery.
Client Object Model
The Client Object Model (Client OM) is an application programming interface that supports extensive, but not full interaction with the SharePoint configuration and data. It was added with the SharePoint 2010 release to provide an easy way to interact with SharePoint configuration and data without the need for code deployed to the server. It puts a simple wrapper around the previously discussed web services simplifying the interaction and removing the need to create and parse the XML needed to interact with the Web services. The client-side code can be called from Silverlight, ECMAScript, or via your .Net code.
The Client OM can be used to include the Ajax enabled features allowing content and data refreshes or loads without the need for a page post back which reloads or redirects the page.
The Client OM is limited in that it cannot connect or perform calls outside of the site context that it is called from. This means that it cannot be used for cross-site calls or aggregating content from multiple web applications or site collections.
There are also some functions available in the Server OM that are not supported in the Web services and therefore not supported in the Client OM due to security boundaries.
Frequently Used Objects and Collections include:
Good candidates for Client OM solutions include:
- Modular visualizations or content, similar to a web part
- Enhancing DataForm Web Parts
- Silverlight solutions
- Page level customizations and enhancements
Using jQuery
The jQuery library (http://jquery.com/) can be leveraged to support client-side development and Ajax enabled functions. This JavaScript based library is completely cross-browser compliant and offers a rich set of selectors and advanced support for animations that can be used to provide a much richer interface than static HTML. This library is completely platform independent, and there is nothing SharePoint specific about this library. Since there are a number of Ajax methods that make it easy to consume web services, you can use the library to interact with SharePoint through its web services.
In its base format, you would need advanced knowledge of all of SharePoint's web services. To help simplify the development effort the SPServices library (http://spservices.codeplex.com/) was created to provide a wrapper around SharePoint's web services. This library was created in the Sumer of 2009 originally for the SharePoint 2007 version, but it is also fully functional with SharePoint 2010. While it conceptually offers the same functionality as the Client OM, it could be used for solutions that need to be backward compatible with 2007 or in cases where there is a SPServices method not supported in the current Client OM.
Good candidates for jQuery Solutions include:
- Modular visualizations or content, similar to a web part
- Enhancing DataForm Web Parts
- Page level customizations
Deploying and managing client-side customizations
There are a number of ways to deploy and manage client-side code inside of SharePoint. You can add it directly to your SharePoint page using a tool like SharePoint Designer, or you can add it to a container such as the Content Editor Web Part that is included with each of the SharePoint versions. In cases where you use the Content Editor Web Part, you also have the option of linking to your content or script stored in any network accessible location.
It is important to consider how changes and versions will be managed. If you are adding code and functionality to pages, you should have versioning configured for the library the pages are in, as well as any libraries used to store your scripts. This will allow you to compare versions or to recover a prior version if things go wrong.
Many environments have very strict change management or deployment guidelines for any code that is deployed to the server by administrators. One of the big advantages to the client-side development approach is that system users with appropriate access can deploy their customizations themselves without the involvement of the administrators or change control group. This typically means that customizations can be created and deployed very quickly without all of the formality needed for the more advanced customizations. While there is some risk that a defective customization will cause an error or unexpected results, the impact is typically localized to the page the customization is used on or the content it interacts with.