Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Microsoft SharePoint 2010 Developer's Compendium: The Best of Packt for Extending SharePoint

You're reading from   Microsoft SharePoint 2010 Developer's Compendium: The Best of Packt for Extending SharePoint Build an engaging SharePoint site with Visual Studio, Silverlight, PowerShell and Windows 7 Phone with this book and e-book

Arrow left icon
Product type Paperback
Published in Feb 2012
Publisher Packt
ISBN-13 9781849686808
Length 392 pages
Edition 1st Edition
Arrow right icon
Toc

Table of Contents (15) Chapters Close

Microsoft SharePoint 2010 Developer's Compendium: The Best of Packt for Extending SharePoint
Credits
About the Contributors
1. www.PacktPub.com
2. Preface
1. Understanding SharePoint Development Choices 2. Building an Engaging Community Site FREE CHAPTER 3. PowerShell Scripting Methods and Creating Custom Commands 4. Integrating Silverlight 4 with SharePoint 2010 5. Interacting with Rich Media and Animations 6. List Definitions and Content Types 7. Workflows 8. Introduction to Programming Windows Phone 7 with the SharePoint Client Services 9. Building SharePoint Pages for Windows Phone 7 10. Building a Windows Phone 7 Dashboard Application with SharePoint Data

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:

Object

Description

ClientContext

Represents current Context, and is used as the main entry point for interacting with the Client OM.

Site

Represents a Site Collection

Web

Represents a Web or Sub-site

WebCollection

Represents the collection of Webs within the Site Collection

List

Represents a List or Library

ListCollection

Represents the collection of lists within the Site Collection

ListItemCollection

Represents the items within a list or library

Field

Represents a single field

FieldCollection

Represents the collection of fields

ListItem

Represents a single list item

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.

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image