1 / 36

Advanced Web Part development in SharePoint 2010

Advanced Web Part development in SharePoint 2010. Eugene Rosenfeld. About me…. Eugene, MVP, MCAD CTO, Black Blade Associates www.blackbladeinc.com Co-founder, BASPUG www.BostonSharePointUG.org Blogger ThingsThatShouldBeEasy.blogspot.com ERosenfeld@BlackBladeInc.com. Intended Audience.

dusty
Download Presentation

Advanced Web Part development in SharePoint 2010

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Advanced Web Part development in SharePoint 2010 Eugene Rosenfeld

  2. About me… • Eugene, MVP, MCAD • CTO, Black Blade Associateswww.blackbladeinc.com • Co-founder, BASPUGwww.BostonSharePointUG.org • BloggerThingsThatShouldBeEasy.blogspot.com • ERosenfeld@BlackBladeInc.com

  3. Intended Audience • 400-level session • Developers • Mid to senior level • Some SharePoint development experience • Not intended to be an “introduction to SharePoint development” session

  4. Agenda • Introduction • Visual Web Parts • AJAX Web Parts • Web Part Page Services • Sandbox Web Parts • Connections to Service Applications • Multi-platform Web Parts

  5. Introduction • VS 2010 now has direct support for SharePoint 2010 artifact creation • Project Templates • Item templates • Solution packages • “F5” build, deploy, debug experience • Designers, with support for XML customization • NOTE: This is V1

  6. Development Environment • F5 deployment and debugging experience requires SharePoint 2010 on same computer as VS 2010 • SharePoint 2010 is 64-bit only, so dev environment must be a 64-bit OS • Windows Server 2008 or 2008 R2 x64 • Windows 7 x64

  7. Visual Web Parts • Think SmartPart, but better • ASCX design surface • Two code files • User control code file – handles events from ASCX design surface • Real web part – loads the ASCX control as a child control at run time

  8. The Good • Familiar ASCX design experience • All web part files (including ASCX) deployed to appropriate 14 hive folders

  9. The Lacking • Still need lots of code • Handle UI events • Handle Web Part tooling • Data Access • Web Part Properties • Web Part Connections • Added layer of code: ASCX and Web Part • Not compatible with Sandbox Solutions • http://SharepointDevTools.codeplex.com

  10. This demo shows a simple visual web part that also has a visual editor part Visual Web Part with Visual Properties

  11. See how to create a visual web part that will run on SharePoint 2007 using Visual Studio 2008 Visual Web Part for SharePoint 2007

  12. AJAX Web Parts • AJAX is automatically enabled by default • No need to explicitly include a script manager on pages that use AJAX • Three approaches: • ASP.Net AJAX • WPSC • ECMAScript

  13. ASP.Net AJAX • Extends ASP.Net server control model with partial page rendering • Compatible with ASP.Net view state • Easiest way to start with AJAX but very “heavy” model

  14. Web Part Page Services • WPSC: Model that simplifies JavaScript Web Part manipulation • Provides: • Discovery • State Management • Notifications

  15. Important Tokens

  16. ECMAScript • Rich model for JavaScript page interaction • Access to • Page • ListView • WebParts • Workflows • Ribbon • Much more

  17. Sandbox Web Parts • Intro Sandboxed Solutions • Sandboxed Solutions Architecture • Restrictions on Sandboxed Code

  18. Intro Sandboxed Solutions • Designed empower site collection admins • Used by • Departments in organizational farms • Hosted site collections in the cloud • Many other multi-tenant scenarios

  19. Sandbox Solutions Architecture • Sandbox code runs in separate process • Sandbox solutions are uploaded to a new site collection gallery • Sandbox solutions have additional restrictions beyond farm solutions

  20. Restrictions on Sandboxed Code • Object model solutions • Data scope restrictions • Artifacts in solution • Code access security • Resource throttling

  21. Connections to Service Applications • Intro to Services Applications • Service Application Architecture

  22. Intro to Services Applications • Evolution of the shared service provider model in SharePoint 2007 • Service applications designed to • Perform long-running operations out side of the web user interface thread • Scale independently of SharePoint web servers • Support cross-farm operations • Potentially invoked from remote farms

  23. Service Application Architecture • Service applications run on configured back-end servers or on other farms • Service application runtime load balances service requests among active service instances • Front-end web servers access services through service proxies

  24. The related contents web part uses the title and description of the current site as the basis for a search query Related Contents Web Part

  25. Web part connections • Connection Model Overview • Connecting to out of the box SharePoint web parts • AJAX Web Part Connections

  26. Connecting to OOTB Web Parts • Connecting to out of the box web parts • Lots of interfaces to implement • Needed interfaces are poorly documented • Interfaces to know: • ListView: IWebPartField, IWebPartRow, IWebPartTable • Filter: IFilterValues

  27. This web part is able to provide data to and consume data from many of the out of the box SharePoint web parts. Connector web part

  28. Multi-platform Web Parts • Platform Detection • Detection Mechanisms • Multi-platform Code

  29. Platform Detection • What are the platforms • WSS V2 / Portal Server 2003 • WSS V3 / Office SharePoint Server 2007 • SharePoint Foundation / SharePoint Server 2010 • Who should care • Product developers • SharePoint hosters • People supporting large deployments

  30. Detection Mechanisms – Object Model • Approach: Try to dynamically load the appropriate SharePoint assembly. Start by loading the higher version numbers first. • Example: • WSS V4 - Microsoft.SharePoint, 14.0.0.0 • MSS 2010 - Microsoft.Office.PortalServer,

  31. Multi-platform Object Model Code • Choice: Use late or early – bound code • Late bound • Don’t need access to each DLL version • No compiler support for error checks • Early bound • Need access to each DLL version • Full compiler support for error checks • Must be careful of where types are declared

  32. Early Bounding Sample private void button1_Click(object sender, System.EventArgs e) { System.Reflection.AssemblyasmWSS; try { //try to load the assembly asmWSS = System.Reflection.Assembly.Load("Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"); } catch(Exception ex) { //the assembly could not load. we assume there is no WSS on this computer asmWSS = null; } if(asmWSS != null) UseWSS(); } private void UseWSS() { //we have a strong reference to an SPSite object Microsoft.SharePoint.SPSite site = new Microsoft.SharePoint.SPSite("http://localhost"); MessageBox.Show(site.GetType().Name.ToString(), "SPSite object created"); }

  33. Late Binding Sample System.Reflection.AssemblyasmWSS; try { asmWSS = System.Reflection.Assembly.Load("Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"); } catch(Exception ex) { //the assembly could not load. we assume there is no WSS on this computer asmWSS = null; } if(asmWSS != null) { //get a late bound reference to the SPSite type //this is equivalent to SPSiteobjSPSite = new SPSite(“http://localhost”); Type typSPSite = asmWSS.GetType("Microsoft.SharePoint.SPSite"); //get a reference to the constructor for SPSite that has this signature: // new Microsoft.SharePoint.SPSite("http://localhost") // and invoke the constructor object objSPSite = typSPSite.GetConstructor(new Type[]{ typeof(string) }).Invoke(new object[]{ "http://localhost" }); }

  34. This web part can run on both versions of SharePoint 2010 and take advantage of the features of each platform. Multi-platform web part

  35. Additional Resources • AJAX – Jan Tielens • http://www.bing.com/search?q=site%3Ahttp%3A%2F%2Fweblogs.asp.net+jan+sharepoint+jquery • Multi-platform Code – Black Blade • http://www.blackbladeinc.com/en-us/community/Pages/Speaking.aspx

  36. Thank you for attending! Eugene Rosenfeld @erosen03 ThingsThatShouldBeEasy.blogspot.com ERosenfeld@BlackBladeInc.com

More Related