Client Side AJAX Applications in SharePoint 2010 – Part 1: Introduction
Guest Author: Lee Richardson
From a developer’s perspective WCF Data Services is one of the most compelling new features of SharePoint 2010. Using this technology in conjunction with ASP.Net AJAX 4.0 Templating, SharePoint developers can quickly build rich, responsive, web 2.0 user interfaces. And unlike with Silverlight based solutions end users won’t need anything beyond a modern browser.
But best of all, solutions based on the approach outlined in this series won’t require customizing SharePoint at all. No custom web parts, no site definitions, no application pages necessary. Everything in this series will work with plain content editor web parts and (nearly) out of the box SharePoint (it will require installing WCF Data services, but it’s free and it’s from Microsoft).
First a word of warning: This series will contain no C# whatsoever (or VB for that matter). There will be no compilation, and none of the benefits it brings: no type checking, no syntax checking, no LINQ to objects, no LINQ to SharePoint. And the kicker: there will be mediocre IntelliSense support from Visual Studio.
Why Would You Do This to Yourself?!
- It’s slow
- It sends the entire ViewState with every asynchronous request (this can actually sneak up on you once you have a lot of production data as happened to me recently)
- Even without a ViewState the UpdatePanel transmits large amounts of HTML (rather than lightweight JSON data)
- It runs through the entire page lifecycle on updates, executing everything on the page even if it isn’t relevant to what you’re doing
- ASP.Net AJAX doesn’t have the simplicity of an ETag based HTTP caching like with a REST solution
- Finally SharePoint just doesn’t work well with UpdatePanel (I can’t tell you how many issues I’ve had with various controls not working out of the box)
- You have to write a lot of plumbing code
- You have to write a service to return your data
- You have to pay particular attention to security and permissions since you’re exposing your API’s to the world
- You have to convert your data (ideally JSON) into HTML with either
- String concatenation
- Document.createElement statements, or
- Some less than ideal JQuery syntax
- Your UI code is not clearly separated from your data access code making your code hard to maintain
- Saving data back to the server involves even more plumbing code and permissions issues
SharePoint 2010 and WCF Data Services combined with ASP.Net AJAX 4.0 Templating provide a very nice solution for all of these problems. The next article in the series will detail more of WCF Data Service. Future articles in the series will build up a simple application for managing user stories as index cards on a virtual cork board with jQuery and more importantly ASP.Net AJAX 4.0 Templating.
Guest Author: Lee Richardson
Lee Richardson is a Senior Software Engineer at Near Infinity Corporation, an enterprise software development and consulting services company based in Reston, Virginia. He is a Microsoft Certified Solution Developer (MCSD), a Project Management Professional (PMP), a Certified SCRUM master and has over ten years of experience consulting for the public and private sector. You can follow Lee on Twitter at @lprichar
- Client Side AJAX Applications in SharePoint 2010 – Part 1: Introduction
- Client Side AJAX Applications in SharePoint 2010 – Part 2: WCF Data Services
- Client Side AJAX Applications in SharePoint 2010 – Part 3: ASP.Net AJAX Templating 101
- Client Side AJAX Applications in SharePoint 2010 – Part 4: jQuery Integration and Persistence
- Client Side AJAX Applications in SharePoint 2010 – Part 5: Modal Dialogs
- Client Side AJAX Applications in SharePoint 2010 – Part 6: Master-Details
- Client Side AJAX Applications in SharePoint 2010 – Part 7: Live Bindings