Share Point 2010 Developer Evaluation Guide BETA Oct2010

download Share Point 2010 Developer Evaluation Guide BETA Oct2010

of 123

Transcript of Share Point 2010 Developer Evaluation Guide BETA Oct2010

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    1/123

    1 www.microsoft.com/sharepoint

    Microsoft SharePoint 2010Professional Developers Evaluation Guide

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    2/123

    Copyright

    This is a preliminary document and may be changed substantially prior to final

    commercial release of the software described herein.

    The information contained in this document represents the current view of Microsoft

    Corporation on the issues discussed as of the date of publication. Because Microsoft

    must respond to changing market conditions, it should not be interpreted to be a

    commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of

    any information presented after the date of publication.

    This white paper is for informational purposes only. MICROSOFT MAKES NO

    WARRANTIES, EXPRESS, IMPLIED, OR STATUTORY, AS TO THE INFORMATION IN THIS

    DOCUMENT.

    Complying with all applicable copyright laws is the responsibility of the user. Without

    limiting the rights under copyright, no part of this document may be reproduced, stored

    in, or introduced into a retrieval system, or transmitted in any form or by any means

    (electronic, mechanical, photocopying, recording, or otherwise), or for any purpose,

    without the express written permission of Microsoft Corporation.

    Microsoft may have patents, patent applications, trademarks, copyrights, or other

    intellectual property rights covering subject matter in this document. Except as expressly

    provided in any written license agreement from Microsoft, the furnishing of this

    document does not give you any license to these patents, trademarks, copyrights, or

    other intellectual property.

    Unless otherwise noted, the example companies, organizations, products, domain

    names, e-mail addresses, logos, people, places, and events depicted herein are fictitious,

    and no association with any real company, organization, product, domain name, e-mail

    address, logo, person, place, or event is intended or should be inferred.

    2009 Microsoft Corporation. All rights reserved.

    Microsoft SharePoint Server 2010,Microsoft Visual Studio 2010,Microsoft SharePoint

    Designer 2010, Microsoft Office InfoPath, Microsoft Office Visio are trademarks of the

    Microsoft group of companies.

    All other trademarks are property of their respective owners.

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    3/123

    www.microsoft.com/sharepoint

    Contents

    Abstract..................................................................................................................................................................... 1Introduction ............................................................................................................................................................ 1Summary of Whats New .................................................................................................................................. 2Key Types of Solutions Built on SharePoint by Developers .............................................................. 3

    Building Applications on SharePoint ...................................................................................................... 3Business Collaborative Applications .................................................................................................. 4User Interface Portal for Line of Business Application Data .................................................... 5Customizing Out-of-Box Workloads.................................................................................................. 5One Web Part Solutions .......................................................................................................................... 8

    Improved Developer Productivity with Better Tools ............................................................................ 8Visual Studio 2010 SharePoint tools ....................................................................................................... 8Visual Studio 2010 SharePoint tools extensibility ...........................................................................13Developer Workstation support for Windows 7 and Windows Vista SP1 ...........................14Upgrading from Visual Studio 2008 extensions for SharePoint to Visual Studio 2010

    SharePoint tools .............................................................................................................................................14SharePoint Designer 2010 .........................................................................................................................16

    SharePoint Designer 2010 Workflow Design ...............................................................................18SharePoint Designer 2010 Business Connectivity Services Design ....................................19

    Developer Dashboard ..................................................................................................................................21SharePoint 2010 Application Lifecycle Management ....................................................................23

    Better Solutions with Rich Platform Services .........................................................................................24User Interface...................................................................................................................................................25

    Building User Interface ...........................................................................................................................27The SharePoint 2010 Ribbon ...............................................................................................................27The SharePoint 2010 Dialog Framework ........................................................................................28New Silverlight Web Part ......................................................................................................................29

    Data and Programmability ........................................................................................................................30

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    4/123

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    5/123

    1 www.microsoft.com/sharepoint

    AbstractThis evaluation guide is designed to give you an overview of the feature set and

    extensibility points for Microsoft SharePoint 2010 and an understanding of how the

    professional developer can use these features and extensibility points to create

    comprehensive solutions. This guide begins with an overview of the types of solutions

    that you can build by developing on SharePoint. It then covers the developer tools for

    SharePoint 2010, the new platform features and the solution deployment

    enhancements. The guide concludes with six walkthroughs showing example developer

    customizations in SharePoint 2010.

    The ultimate goal of this guide is to provide a framework for an effective evaluation of

    SharePoint 2010 as a solution creation platform. This guide is intended for the

    professional developer, development lead, and software architect. Also available are an

    evaluation guide focused on SharePoint 2010 the product and an evaluation guide for

    the IT Professional.

    For the latest information about SharePoint 2010, go to

    http://SharePoint.Microsoft.com. For other product information resources, refer to the

    Learning More section in this guide. Feedback on this guide can be emailed to

    [email protected].

    IntroductionWelcome to the professional developers evaluation guide for Microsoft SharePoint

    2010. The goal of this guide is to help you gain sufficient knowledge and understanding

    of SharePoint 2010 to evaluate this product from Microsoft.

    SharePoint 2010 provides the business collaboration platform for developers to rapidly

    build solutions using familiar tools while leveraging a rich set of out of the box features.

    Visual Studio 2010 and SharePoint Designer 2010 make developers more productiveand Visual Studio Team Foundation Server delivers support for application lifecycle

    management. Developers can integrate Line of Business data in SharePoint 2010 with

    read/write capability delivered by Business Connectivity Services. Sandboxed Solutions

    can be deployed to a shared hosting environment to limit the impact of unpredictable

    code to the other applications in use.

    http://sharepoint.microsoft.com/http://sharepoint.microsoft.com/mailto:[email protected]?Subject=DeveloperEvaluationGuidemailto:[email protected]?Subject=DeveloperEvaluationGuidemailto:[email protected]?Subject=DeveloperEvaluationGuidehttp://sharepoint.microsoft.com/
  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    6/123

    2 www.microsoft.com/sharepoint

    SharePoint 2010 is a major step forward for SharePoint as a development platform not

    only because of the richer set of overall features that the platform supports but also

    because significant investments have been made in the suite of tools to make

    developers more productive, and also more accessible to developers of all skill levels.

    This guide will walk you through some of the most compelling enhancements to theSharePoint 2010 platform for developers.

    Summary of Whats NewSharePoint 2010 includes numerous new capabilities and features for professional

    developers most of which are highlighted in this document. Here is a summary of whats

    new.

    Developer Productivity

    Visual Studio 2010 SharePoint Project Types and Items

    Visual Studio 2010 SharePoint tools extensibility

    Visual Studio Extensions For SharePoint Upgrade

    Windows 7 and Windows Vista Operating System Support

    SharePoint Designer 2010

    Developer Dashboard

    Team Foundation Server 2010 Integration

    Rich Platform Services

    SharePoint Ribbon

    SharePoint Dialogs

    Silverlight Web Part

    List Lookups and Relationships

    Business Connectivity Services

    LINQ to SharePoint

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    7/123

    3 www.microsoft.com/sharepoint

    Performance Enhancements

    Solution Throttling

    Event Enhancements

    Workflow Enhancements

    Client Object Model

    REST APIs

    Flexible Deployment

    Sandboxed Solutions

    SharePoint Online

    Upgrading Solutions

    In this guide we will walk through all of the new features in SharePoint 2010 that pertain

    to professional software developers. First we will briefly discuss some key types of

    solutions that can be built by developers by leveraging the benefits of SharePoint 2010.

    Key Types of Solutions Built on SharePoint byDevelopersDevelopers create solutions every day. SharePoint 2010 makes developing those

    solutions easier, quicker, and more flexible. Much of the work that the developer had to

    do in the past with earlier versions of SharePoint has been replaced with simple

    configuration of the SharePoint 2010 platform, use of Visual Studio 2010 and SharePoint

    Designer 2010 or with calls to the SharePoint API.

    Building Applications on SharePointSharePoint as a platform for application development has really spread its wings with

    the release of SharePoint 2010. Organizations can get greater productivity by

    capitalizing on the out of the box features and rich extensibility of SharePoint.

    Visual Studio 2010, SharePoint Designer 2010, and the SharePoint web user interface

    accelerate development. By providing tools targeted for different types of users and a

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    8/123

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    9/123

    5 www.microsoft.com/sharepoint

    social features allow larger teams and even the entire organization to find valuable

    content developed through the collaborative process.

    We have moved from an era of data into an era of information and with the features of SharePoint 2010

    we can move into an era of personal information.

    User Interface Portal for Line of Business Application Data

    Just as line of business systems are a key need for organizations, so too are front end

    systems which can help get information into the core line of business (LOB) systems that

    drive the transactional and production throughput of the organization. Traditional LOB

    systems have a core set of users who are well educated in their use and a much broader

    audience of users who are less trained and whom interact only in limited or occasional

    ways.

    The integration of SharePoint 2010 with back end systems through Business

    Connectivity Services (formerly known as Business Data Catalog), allows SharePoint to

    be used to deliver data to the LOB systems. For instance, purchase order requests can

    be routed for approval in SharePoint via a workflow and delivered to the back end

    system pre-approved. Similarly, a Word form can be created which reads from the LOB

    system to look up the customer and product descriptions. The end result of the form

    can be an order in the sales order system. The ability to read information from the LOB

    system and to write back changes makes it easy to integrate SharePoint 2010 and

    Office 2010 into your existing back end systems.

    Customizing Out-of-Box Workloads

    SharePoint 2010 offers six out of the box workloads as shown in Figure 1. These

    capabilities make SharePoint a powerful platform for any user and a powerful platform

    for extension by a developer.

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    10/123

    6 www.microsoft.com/sharepoint

    Figure 1 SharePoint 2010 Capabilities

    More detail about each of these workloads can be found in the SharePoint 2010

    Evaluation Guide, this Developer Evaluation Guide will overview the extensibility points

    that developers can customize. Some of the ways that professional developers can

    customize and extend them as shown in this table:

    Capability Out of the Box features Extensibility points

    Sites The capability to store and

    retrieve both list and

    document content in an

    easy and flexible way with

    connectivity to the

    Microsoft Office client

    applications.

    Web Parts, Master Pages,

    Pages, Delegate Controls,

    InfoPath Forms, and

    solutions leveraging the

    Word File Conversion

    Service. Access Services for

    deploying Access solutions

    to SharePoint.

    Communities The capability to locate and

    interact with people

    through expertise,

    relationships, tagging, and

    rating of content.

    Predefined searches, search

    web parts, tagging

    interfaces, rating interfaces,

    and custom user interfaces

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    11/123

    7 www.microsoft.com/sharepoint

    Content The capability to manage

    content whether that

    content is a web page, a

    document, or a set of

    documents and recordsmanagement of the content

    that is created.

    Custom page types, field

    controls, content types,

    document sets, remote

    blog storage providers,

    workflows and WordServices. Records

    management extensibility

    and Public Web Sites

    extensibility.

    Search The capability to search

    content inside and outside

    of SharePoint including

    information in structured

    database systems.

    Predefined search result

    transformations, web parts

    leveraging search for

    navigation and location of

    content, and connections to

    back end systems. Also

    IFilters and Protocol

    Handlers.

    Insights The capability to leverage

    Excel to access and display

    data on a web page,

    Dashboards, and Key

    Performance Indicators to

    transform raw data into

    actionable information.

    Excel Services, Excel User

    defined functions, key

    performance indicators, and

    dashboards

    Composites The capability for business

    users to create their own

    solutions through

    connection andarrangement of the features

    of the platform.

    Web parts, workflows and

    InfoPath Forms Services

    that increase the tools

    available for the end user.

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    12/123

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    13/123

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    14/123

    10 www.microsoft.com/sharepoint

    Figure 2 SharePoint Project Types in Visual Studio 2010

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    15/123

    11 www.microsoft.com/sharepoint

    Figure 3 SharePoint Item Templates in Visual Studio 2010

    Each project wizard guides you through the process by asking what site you want to use

    to deploy and debug your solution. It also asks whether the result of the project will be

    deployed as a sandboxed solution as shown in figure 4.

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    16/123

    12 www.microsoft.com/sharepoint

    Figure 4 Project wizard connects the development environment to a SharePoint instance

    Visual Studio 2010 also includes support for viewing SharePoint 2010 sites through the

    Server Explorer. You can now use Server Explorer to look at all of the SharePoint settings

    for sites, lists, content types, workflow associations, and other objects. This allows you tonavigate and view SharePoint sites. It simplifies the process of checking code against the

    implementation in the system because all of the implementation details available to you

    in the Visual Studio 2010 environment. For document libraries and lists it also gives you

    quick access to an artifact you view in the Server Explorer with a link to the SharePoint

    Web UI. Figure 5 shows the Server Explorer with a SharePoint site open.

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    17/123

    13 www.microsoft.com/sharepoint

    Figure 5 Server Explorer allows you to navigate SharePoint

    Visual Studio 2010 SharePoint tools extensibility

    Visual Studio 2010 provides a rich set of project templates and tools that developers can

    use to create custom SharePoint solutions. Although these SharePoint projects and tools

    work well for many application development scenarios, there may be times when

    different or new functionality is needed. In these cases, you can adapt the SharePoint

    projects and tools in Visual Studio by using a new Visual Studio extensibility Application

    Programming Interface (API).

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    18/123

    14 www.microsoft.com/sharepoint

    This API lets you create new SharePoint project items, automate and extend existing

    SharePoint project items, enhance packaging, validation, deployment and retraction,

    extend the SharePoint nodes in Server Explorer, and even create new designers.

    Developer Workstation support for Windows 7 and Windows Vista SP1SharePoint 2010 makes great advances in the development environments that can be

    used to create SharePoint solution. In addition to a broader set of tools for developing

    solutions for SharePoint the requirement to be running on a server operating system

    has been relaxed so that it is possible to develop applications on a local developer

    workstation running a client operating system like Windows 7. Support for Windows 7,

    Windows Vista Service Pack 1, in addition to Windows Server 2008 means that

    developers can build on a non-server OS locally and then deploy to a server running

    Windows Server 2008 for integration, testing, and production.

    It is important to note that SharePoint 2010 is only available as 64 bit version and

    therefore the operating system, whether client or server, must be a 64 bit version.

    Upgrading from Visual Studio 2008 extensions for SharePoint to Visual

    Studio 2010 SharePoint tools

    Visual Studio 2010 provides developers with many resources to help upgrade their code

    from Office SharePoint Server 2007 to SharePoint 2010.

    Projects based on the Visual Studio 2008 workflow project templates are upgradedautomatically by Visual Studio 2010 to equivalent projects which still target Office

    SharePoint Server 2007 but can now be developed in Visual Studio 2010. All other

    SharePoint projects in Visual Studio 2010 target SharePoint 2010.

    Projects based on the Visual Studio 2008 extensions for Windows SharePoint Services

    (VSeWSS) project templates can be upgraded to equivalent projects targeting

    SharePoint 2010 and continued development on Visual Studio 2010. An upgrade tool is

    available that upgrades these projects to the new project and packaging format of the

    Visual Studio 2010 SharePoint tools. Figures 6 and 7 show the wizard that walks you

    through the upgrade process.

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    19/123

    15 www.microsoft.com/sharepoint

    Figure 6 Visual Studio Extensions for Windows SharePoint Services Import Step 1

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    20/123

    16 www.microsoft.com/sharepoint

    Figure 7Visual Studio Extensions for Windows SharePoint Services Step 2

    SharePoint Designer 2010

    SharePoint Designer 2010 is a fully functional participant in the solution creation

    lifecycle for SharePoint 2010. Applications can be created with the SharePoint web user

    interface and with SharePoint Designer 2010 as complete applications. Or they can be

    packaged into a SharePoint Solution (WSP) file that can be imported into and further

    edited by Visual Studio 2010. For example a declarative re-usable workflow can be

    prototyped in SharePoint Designer 2010 and moved in to Visual Studio 2010.

    The ability of the farm administrator to control of usage of SharePoint Designer 2010

    has been substantially improved. You can now specify which SharePoint Designer

    features are available at a web application and site collection level. This will make it

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    21/123

    17 www.microsoft.com/sharepoint

    easier for organizations to allow SharePoint Designer in some areas of a site and restrict

    it in others.

    From the perspective of the user of SharePoint Designer the fundamental approach has

    changed. Instead of being focused on pages and as a HTML/CSS editor, it is been

    refocused around the artifacts that you create in SharePoint. Sometimes the artifact that

    you are creating with SharePoint designer is a master page but more often it is the

    implementation for lists and libraries, workflows, content types, data sources, entities, or

    site level settings. Figure 8 shows the primary left navigation menu of SharePoint

    designer which highlights the new focus on SharePoint artifacts.

    Figure 8SharePoint Designer navigation is SharePoint Site focused

    A site dashboard in SharePoint Designer 2010 allows you to see at a glance the basic

    information about the site. The navigation bar allows you to navigate into more details

    about the specific lists and libraries. Figure 9 shows the site dashboard for a site

    including the basic site information, permissions, and sub-sites.

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    22/123

    18 www.microsoft.com/sharepoint

    Figure 9 SharePoint Designers Site Dashboard provides an at a glance view of the SharePoint site

    SharePoint Designer 2010 Workflow DesignIn SharePoint Designer 2010 the workflow design experience is a perfect example of

    how a business analyst can access a tool that can be leveraged as the first step in a

    development cycle. The workflow designer in SharePoint Designer 2010 allows you to

    specify a set of steps, conditions, and actions that fit together into a sequential

    workflow. The designer allows you to create complex workflows that include looping

    and branching by clicking a few buttons in the ribbon. By assembling the out of the box

    actions and custom actions it is possible to develop workflows which do not require any

    custom code.

    The user interface for building the workflow is a full page, artifact model which allows

    you to develop a workflow like any other SharePoint artifact by referring to other

    resources and potentially making changes to lists and content types while building the

    workflow.

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    23/123

    19 www.microsoft.com/sharepoint

    Those workflows that are developed in SharePoint Designer 2010 can be exported into a

    SharePoint Solution Package file (WSP) so that they can be imported in Visual Studio

    2010 and from there enhanced or changed. Workflows can also be designed in Visio

    and imported into SharePoint Designer and Figure 10 shows the Approval workflow

    when visualized with Microsoft Visio.

    Figure 10Microsoft Visio can visualize workflows

    The workflow editor in SharePoint Designer 2010 has two basic modes. A non-reusable

    workflow mode which uses the specific attributes of a list and embeds those fields,

    content types, etc., into the workflow and the reusable workflow which can be packaged

    for redeployment. The non-reusable workflow allows for a simpler design experience

    when the workflow will only ever need to exist in one place. The reusable workflow can

    be reused anywhere so therefore does not bring context from the current site and

    thus requires more work to deliver. Having both allows the developer to decide which

    workflow solution is best for the specific scenario.

    SharePoint Designer 2010 Business Connectivity Services Design

    Workflows operate on SharePoint data or any data that SharePoint can operate on.

    Business Connectivity Services extends that reach of workflows and other SharePoint

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    24/123

    20 www.microsoft.com/sharepoint

    features to data outside of SharePoint. SharePoint Designer 2010 makes the process of

    defining external entities easy. A wizard guides you through making connections to an

    external system whether it is Windows Communication Foundation (WCF) Service, a

    Web Service, a .NET class, or a database. Once the connection is made you will see a list

    of the entities. By right clicking on the entity you can have SharePoint Designerautomatically generate the actions needed to support the entity. Within just a few

    minutes you can create the connections for all of the tables in your database and

    connect those to external lists in SharePoint. Figure 11 shows the AdventureWorks

    customer entity that was created by connecting to the Microsoft SQL Server

    AdventureWorks sample database.

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    25/123

    21 www.microsoft.com/sharepoint

    Figure 11 The Entity information for a database connected customer entity

    Developer Dashboard

    Developing any complex system creates the opportunities for unexpected interactions.

    In most complex systems determining what part of the system is causing a delay or is

    consuming resources is difficult. SharePoint 2010 solves this problem by providing a

    developer dashboard which can be turned on as needed. The developer dashboard

    records and displays performance statistics related to the code that executed to

    produce the page. Tracking involves both elapsed time as well as the load placed on the

    system by queries and tracking of exceptions.

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    26/123

    22 www.microsoft.com/sharepoint

    You can turn on the Developer Dashboard by running the following stsadm command:

    stsadm -o setproperty -pn developer-dashboard -pv OnDemand

    Once enabled, you can turn the Developer Dashboard on and off by clicking on theDeveloper Dashboard action in the upper right corner of any page, see figure 12.

    Figure 12: Developer Dashboard command

    By turning on the detailed view via a link in the developer dashboard itself you get a

    function-by-function level trace of the time that was taken during the page load in

    addition to the tracing provided by ASP.NET. This allows the developer to pinpoint

    exactly which components on the page is generating load on the system and which

    components are causing the page load time. Figure 13 shows both the summary view of

    the developer dashboard without the extended tracing.

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    27/123

    23 www.microsoft.com/sharepoint

    Figure13 - The Developer Dashboard Shows the Elapsed Time of Every Operation

    SharePoint 2010 Application Lifecycle Management

    The lifecycle for development in SharePoint 2010 includes business analysts as well as

    end users. End users and analysts develop the foundation for the solution they want in

    the web user interface and in SharePoint Designer 2010. SharePoint Designer 2010 can

    export changes into the standard SharePoint Solution Package (WSP) which can be

    imported into Visual Studio 2010 and used as the starting point for coding

    development. By connecting the rapid prototyping phase of a project and directly

    linking it into the development process developer productivity is greatly enhanced.

    Further, because there is no loss between the work done in the web UI and SharePoint

    Designer, the end users and business analysts can truly start the development process

    and turn the artifacts over to the developer when there are features that cannot be

    created with the web and SharePoint Designer.

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    28/123

    24 www.microsoft.com/sharepoint

    By connecting the end user and business analyst work with the developer, SharePoint

    facilitates a rapid development process where the user is encouraged to start the

    development process.

    Visual Studio 2010 also supports tight integration with Visual Studio Team Foundation

    Server which includes both source control and team builds. Figure 14 shows the

    definition of a specific build definition for SharePoint projects.

    Figure 14 SharePoint Project Specific build process implemented in Team Foundation Server

    Better Solutions with Rich Platform ServicesSharePoint 2010 is a rich platform on which you can build your application. The

    Microsoft .NET framework provides base level services that developers can import and

    use through code. The SharePoint 2010 platform extends this with additional libraries

    and functionality that can be called directly from developer code. SharePoint also

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    29/123

    25 www.microsoft.com/sharepoint

    provides a set of end user and business analyst tools that integrate tightly into the

    features and APIs available to developers. Figure 15 shows a diagrammatic overview of

    the components of the platform.

    Figure 15 The SharePoint Platform

    User Interface

    The look and feel of SharePoint has radically changed from earlier versions of the

    product. In addition to being more accessible to the user it allows for improved

    extension points and fewer workarounds. The new user interface components that you

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    30/123

    26 www.microsoft.com/sharepoint

    can extend and build applications with include the fluent UI ribbon and an extensible

    dialog system. Figure 16 shows the new home page for the default team site template in

    edit mode.

    Figure 16 The New SharePoint Home Page with the Enhanced User Interface

    SharePoint 2010 supports XSLT views which leverage a standard for transformation of

    information from XML into HTML. XSLT support means that any XSLT editor can help

    you create compelling views. SharePoint Designer 2010 improves on its support for XSLT

    view generation by allowing you to edit the template for an individual item or for the

    overall view. The new XSLT engine provides a mechanism for exporting and reusing list

    views between sites by removing the requirement that a view be associated by a GUID.

    Mixing the display content and code has never been so easy. In SharePoint 2010 thedividing line between content and code has been blurred because web parts can now be

    added as a part of content. This means that you can make your components finer

    grained, gaining even more re-use.

    Web Parts are arguably the most frequently used extension point for SharePoint with

    nearly every project including at least one web part. Developer tooling for creating web

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    31/123

    27 www.microsoft.com/sharepoint

    parts has been extended to Visual Web Parts which manages an ASP.NET User Control

    (ASCX) connected to a web part class. This approach allows the developer to leverage

    the visual designers in Visual Studio 2010 to edit their web parts. This can dramatically

    improve developer productivity over the previous server control-type, non-visual

    approaches.

    Building User Interface

    SharePoint 2010 leverages wiki concepts for managing content and extends these

    concepts by allowing for the inclusion of web parts within the wiki pages themselves. In

    previous versions you were allowed to add web parts to web part zones. In SharePoint

    2010 the developer (and the user) has compete control of the user interface including

    the placement of web parts anywhere on the page. For instance, this means that it is

    possible to put the results of a survey next to text describing the survey. So the results

    of code and content can be comingled on the page to create rich live content scenarios.

    The SharePoint 2010 Ribbon

    The context sensitive ribbon interface is now integrated into the SharePoint 2010 user

    experience. Your applications can extend the ribbon interface to include new menu

    items and options both on a global level and based on the context of the user. Figure

    17 shows how SharePoint changes the ribbon when a user selects a list web part. The

    arrow shows the addition of the List Tools section to the ribbon when the list web part is

    selected.

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    32/123

    28 www.microsoft.com/sharepoint

    Figure 17 - SharePoint Server 2010 allows developers to easily control the entire page experience fromthe menus to the content

    The user interface now also features a status bar immediately below the ribbon to

    indicate the status of the page that you are working on. Not only do you have context

    for where you are on the page by context sensitive menus but the overall settings,

    status, or errors on the page have a consistent location to be displayed as shown in

    figure 18.

    Figure 18SharePoint Server 2010 has a consistent place to communicate status and errors

    The SharePoint 2010 Dialog Framework

    A serious challenge in user interface design for the web is the long page refresh times

    and the constant switching of context from one page to another. SharePoint 2010 has

    solved these concerns through the use of AJAX requests for partial updates and by

    providing a flexible popup dialog framework that allows you to pop up entry boxes on

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    33/123

    29 www.microsoft.com/sharepoint

    top of the existing page. Instead of having users navigate to a new page and then come

    back after the data entry is completed the user stays on the same page and a dialog

    appears above the page.

    The dialogs are just pages which are loaded with a special master page and are

    therefore completely customizable by users and developers to meet their needs. Figure

    19 shows a new announcement being entered in a dialog over a wiki web page.

    Figure 19 Web Dialogs provide quick entry and consistent context

    New Silverlight Web Part

    There are times when the user interface needs to provide a level of interactivity that is

    simply not possible with XHTML technologies. That is where Silverlight steps in.

    Silverlight is the best way to leverage your .NET development skills in creating rich

    interactive experiences for the web. SharePoint now includes native support for

    Silverlight files. Simply develop your Silverlight application (.XAP) and deploy it to the

    server. You can then add the Silverlight application to your web page by adding the

    Silverlight web part and providing the location of the .XAP file. The Silverlight

    application is shown as a part of the page as in the example in Figure 20.

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    34/123

    30 www.microsoft.com/sharepoint

    Figure 20Silverlight brings even richer interactivity to SharePoint 2010

    Data and Programmability

    SharePoint provides a wealth of features and services which allow developers to quickly

    develop solutions to organizational problems. Developers can quickly create solutions

    with relate data, connect to other systems, manage a process flow, and can be deployed

    anywhere.

    SharePoint List Lookups and Relationships

    In a typical system data is somewhat normalized not all of the system's data exists in

    one large table or list. Instead data exists in sets of tables or lists which have one entry

    for each entity across multiple tables. The SharePoint lookup field allows you to connect

    an identifier of one list and to display a different, friendlier field such as name for

    users to select. SharePoint 2010 adds the ability to create additional columns which

    display other fields from another list. In the case of a customer, it is possible to create a

    lookup on the ID of the other list and not only display the customer name but to alsobring across multiple other fields. Figure 21 shows the definition for this customer

    lookup.

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    35/123

    31 www.microsoft.com/sharepoint

    Figure 21 SharePoint 2010 allows you to define lookup fields that bring other fields into the list

    The second major improvement in lookup fields is that they now allow you to enforce

    relationships. You can choose to reject deletes which would otherwise orphan data or

    you can have SharePoint automatically cascade deletes so that when you delete a

    customer all of their invoices are deleted as well. As a result SharePoint 2010 can now beused to create sites which have related data connected in ways familiar to users of

    traditional database tools with the additional user interface options provided by

    SharePoint.

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    36/123

    32 www.microsoft.com/sharepoint

    Business Connectivity Services

    Business Connectivity Services (formerly known as the Business Data Catalog) provides

    access to external data sourced from a Line of Business system, web services or other

    external data provider within SharePoint 2010 and Office 2010 applications. Both

    SharePoint 2010 and Office 2010 applications have product features that can useexternal data directly and tools are also provided in SharePoint Designer 2010 and

    Visual Studio 2010 for working with External Data. Business Connectivity Services is built

    on the Business Data Catalog that was included in Office SharePoint Server 2007 and

    adds write capability, new tools, offline caching from Office Client 2010 applications and

    more.

    Enhancements in the infrastructure configuration allow you to specify which servers can

    manage this process, enhance the ability to locate the profile pages created for the

    entities, and create opportunities for easier connections to existing data sources.

    External lists also provide a greater level of control for the developer because the table

    structure, indexing, and access methods can be customized to improve performance of

    the list or to match internal guidelines. This allows developers to include large lists and

    tables in existing systems in their solutions with the ability to tune the performance as

    they better understand how the users will use the tool.

    Figure 22 shows how the inclusion of BCS creates opportunities to leverage SharePoint

    features and APIs against your existing line of business data that is available via directdatabase access or via web services.

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    37/123

    33 www.microsoft.com/sharepoint

    Figure 22- Architecture of Business Connectivity Services

    LINQ to SharePoint

    LINQ is a new data access paradigm which allows users to express SQL like syntax

    against a variety of data sources. LINQ can improve performance by allowing the back

    end data source to decide the best way to solve the query. SharePoint now fully

    supports LINQ for querying lists so that you can query information from the platform in

    a more condensed, easier to understand format. LINQ also provides strongly typed

    access to data in Visual Studio offering compile time validation to help avoid runtime

    errors. Figure 23 shows a LINQ expression targeting SharePoint.

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    38/123

    34 www.microsoft.com/sharepoint

    Figure 23 Sample method that uses LINQ for SharePoint

    Performance Enhancements

    From optimizations in the code and SQL queries being used to generate SharePoint out

    of the box interfaces, to radical changes in the implementation of views, and greaterflexibility for the use of large lists outside of the core data structures, SharePoint 2010

    will deliver greater performance by reducing choke points in the software related to size

    of data, and improve performance due to more optimized queries.

    SharePoint has been tightened in key spots to yield better performance including XSLT

    view processing and list data operations. The XSLT views have been optimized to

    support SharePoint 2010 emphasis on them. SharePoint list data operation

    improvements include core enhancements as well as the automatic creation of indexes

    on lists when necessary, and improved time to first byte. In addition, SharePoints clientobject model is designed to be batched so that the number of round trips between the

    browser and the server are reduced to improve the overall performance of the client

    object model.

    The use of Sandboxed Solutions (discussed in the section Sandboxed Solutions below)

    allows for the monitoring and management of solutions at a site collection level to limit

    the negative impact of a poorly performing SharePoint Solution Package (WSP) file.

    In addition to the performance monitoring and management for solutions, SharePoint2010 monitors and manages large running queries via application level settings. These

    settings allow you to set limits and warnings when the number of records returned from

    a query is large. There is also an object model override that allows you to enabled

    developers to bypass these limits and exclusion for a time during the day when the

    queries are allowed so that large reports can be generated in batch during the

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    39/123

    35 www.microsoft.com/sharepoint

    evening. Figure 24 shows the Query throttling sections of the Web Application Resource

    Throttling Dialog.

    Figure 24 Query Throttling can be configured for users and administrators with warnings and hard

    limits

    Event Enhancements

    In SharePoint 2010 SPListEventReceiver allows you to track events, including when a list

    is added. SPWebEventReceiver allows you to track web events including webs being

    added and sites and webs being deleted. Figure 25 shows the Visual Studio 2010 wizard

    for creating a web event.

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    40/123

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    41/123

    37 www.microsoft.com/sharepoint

    To create a site-level workflow, you pick the Site Workflow option when creating a new

    workflow with Visual Studio 2010, either by picking one of the workflow project

    templates, or by adding a new workflow to an existing project.

    Figure 26: Site-level workflow option

    Once deployed, site workflow can be started via their initiation page. There is a new

    action under the site actions menu which will display the site workflow page which is a

    dashboard where you can see all the site workflows in your site, start site workflow, and

    monitor their execution.

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    42/123

    38 www.microsoft.com/sharepoint

    Figure 27: Site workflow page

    Enhancements also allow you to run rules only workflows in a non-persisted and

    blocking way. This creates the opportunity to do simple event receiver like activities

    without the need to write code. All that is necessary is to simply declare a rules only

    workflow and associate it with a list. Because these workflows are not allowed to persistto the disk they are run quickly.

    Visio 2010 added support to visualize what step a workflow is in via a Visio diagram. This

    allows users to see not only the current state of the workflow but how many additional

    planned steps there are before completion.

    Document Sets

    Additionally, SharePoint 2010 includes an Enterprise Content Management (ECM)

    feature called document sets. Document sets are a folder like entity that can contain

    other documents and because it is a content type in its own right it can have workflows

    associated with it as well.

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    43/123

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    44/123

    40 www.microsoft.com/sharepoint

    Figure 29 The SharePoint Object Model Options

    Through the use of Windows Communication Foundation (WCF) based services and

    ADO.NET Data Services v.1.5 it is possible to access the WCF services via a REST

    interface. This makes it possible to make a simple web request to get data. This makes iteasy to get access to SharePoint data from any client application. The basic C# code to

    access a REST service (excluding required references) is shown in Figure 30.

    Figure 30Loading data from a list via a web request in C#

    Having the APIs available everywhere makes it possible to integrate to SharePoint from

    a wide variety of applications whether they are sophisticated implementations including

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    45/123

    41 www.microsoft.com/sharepoint

    the latest features like WCF, a web based application, or whether they are a legacy

    application with limited options for integration. By providing a set of similar APIs

    accessible from a client, the server, or the cloud, the benefits provided by SharePoint are

    available to all kinds of applications including those on non-Windows platforms.

    Flexible Deployment Increases the value of SharePoint

    SolutionsThe need to deliver business solutions as cost effectively as possible has lead

    organizations to share platforms between applications. Servers and farms are being

    tasked with supporting dozens of applications, not just one or two applications as they

    have in the past. This creates challenges for centralized infrastructure teams that are

    tasked with maintaining a stable platform for all of the developers who are creatingsolutions. SharePoint 2010 has a set of solutions that are specifically designed to allow

    for this shared platform scenario like the one run by Microsoft itself in the SharePoint

    Online offering.

    Sandboxed Solutions

    SharePoint 2010 has significant improvements for multi-stakeholder scenarios where it

    is necessary to provide a level of isolation between different sets of code both from a

    security perspective as well as from the perspective of maintaining performance.

    Sandboxed Solutions are SharePoint Solution Package files (WSP files) that are limited in

    what they can do and in the server resources they can use. What they can do is limited

    using Process Isolation and Code Access Security limited to the SharePoint Site. The

    resources they can use are limited by process monitoring, logging and log aggregation.

    Any individual action is limited and the solution is also given a daily limit of resources.

    This provides for a complete isolation system that ensures code running in a sandboxed

    solution cannot reach out to access information beyond the scope of the deployment.

    Specifically, sandboxed solutions will not be able to make updates to the SharePointobject model beyond the scope of the SPSite object. Farm level and web application

    level changes are allowed only for read operations. Figure 31 shows how the process

    works from retrieving the code to returning the results to the user.

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    46/123

    42 www.microsoft.com/sharepoint

    Figure 31 SharePoint Sandboxed Solution Execution

    Each Sandboxed Solution is stored in a solution gallery similar to the web part gallery.

    SharePoint tracks and displays the resource usage as an abstract concept called points.

    Administrators can set a maximum number of points that a site collection can use

    through quotas. When the utilization of the site collection exceeds its quota solutions

    are be temporarily disabled. This prevents a single site collection from consuming all of

    the resources on the server farm. Resource limits for Sandboxed Solutions are designed

    to avoid disruption of Document Library users on the same server.

    Figure 32 shows a site collection with 300 resources allocated and a solution calledBadWSP which has consumed 0.12 resources to date.

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    47/123

    43 www.microsoft.com/sharepoint

    Figure 32 Sandboxed Solution resource management

    SharePoint Online

    SharePoint Online is a shared hosting service and in the 2007 version it does not allow

    for custom code to be uploaded in the standard offering. Custom code is only allowed

    on dedicated farms and then only after an exhaustive review. Sandboxed Solutions in

    SharePoint 2010 will enable SharePoint Online to allow user provided code to be

    installed on the shared platform. This opens a new arena for developers who want to

    create solutions for their customers who want to use hosting instead of maintaining

    their own servers.

    Upgrading Solutions

    As developers revise solutions on the platform, SharePoint 2010 provides upgrade

    semantics in the WSP file to allow for seamless upgrade of developer provided solutionsfrom one version to another.

    The addition of upgrading semantics includes support for including

    elements in the web.config file to allow redirection from one assembly version to

    another, the inclusion of a version for features and syntax around upgrade actions that

    should be performed based on what version range the feature was before being

    upgraded.

    A new FeatureUpgrading event is raised when a feature is being upgraded from aprevious version to a new version. This allows developers to capture and upgrade any

    items in the feature which cannot be upgraded via the declarative XML syntax.

    In addition, new API methods exist to make it easier for developers and administrators

    to identify which features are activated across the farm and what version those features

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    48/123

    44 www.microsoft.com/sharepoint

    are. This makes it easy for developers to see where their features are activated and

    which locations the feature hasnt been upgraded yet.

    Learning Morehttp://msdn.microsoft.com/SharePoint: SharePoint MSDN Developer Center

    http://MSSharePointForums.com: SharePoint Forums

    http://MSSharePointConference.com: The Microsoft SharePoint Conference

    http://MSSharePointDeveloper.com: Introductory Training For Developing on

    SharePoint

    ConclusionWhether the challenge that you are trying to solve is a simple one-off application with a

    few data tables or the front end for an enterprise solution that drives the organization,

    SharePoint 2010 and the Office 2010 clients provide the tools you need to manage your

    data, support your users, and connect the processes. As a developer using SharePoint

    you are not tied to tediously building interactive edit screens, buried in building

    architecture, or stymied by building security. Building on the benefits of the SharePoint

    platform allows you to get more done.

    http://msdn.microsoft.com/SharePointhttp://msdn.microsoft.com/SharePointhttp://mssharepointforums.com/http://mssharepointforums.com/http://mssharepointconference.com/http://mssharepointconference.com/http://mssharepointdeveloper.com/http://mssharepointdeveloper.com/http://mssharepointdeveloper.com/http://mssharepointconference.com/http://mssharepointforums.com/http://msdn.microsoft.com/SharePoint
  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    49/123

    45 www.microsoft.com/sharepoint

    SharePoint 2010 Developer WalkthroughsThe following code walkthroughs demonstrate some of the new functionality available

    to developers of SharePoint 2010. Screenshots are provided so that if you do not have a

    SharePoint 2010 installed machine you can still review the steps that would be taken

    and the outcome that you would see.

    Walkthrough 1: Using LINQ to SharePoint from within a Visual web part

    Exercise Duration: 10 minutes

    Exercise Overview

    This example demonstrates how to use the SharePoint LINQ provider to read data from

    a SharePoint list and render the data using the SPGrid web control. It shows thesecreated in the Visual Web Part designer in Visual Studio 2010.

    Task 1: Create a new Empty Project and add a Visual Web Part

    1. Open Visual Studio 2010 from the Start | Programs | Visual Studio 2010

    menu.

    2. Create a new project by using File | New Project.

    3. Pick the SharePoint | 2010 templates.

    4. From the SharePoint | 2010 templates select the Visual Web Part projecttemplate.

    5. Use SPLinqSolutionDemo as the name of the project.

    6. UseC:\SPHOLsas the location.

    7. Press OKto create the project.

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    50/123

    46 www.microsoft.com/sharepoint

    8. When the SharePoint Customization Wizard dialog appears, select the site you want to

    deploy the Web Part to. Click the Finish button to complete the project creation process.

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    51/123

    47 www.microsoft.com/sharepoint

    9. Within Solution Explorer expand VisualWebPart1 and open VisualWebPart1.webpart.

    a. Set the title element to: SPLinqDemoPart Titleb. Set the description element to: SPLinqDemoPart Description

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    52/123

    48 www.microsoft.com/sharepoint

    Task 2: Generate LINQ to SharePoint proxy class to access list data.

    1. Start a Visual Studio 2010Command Prompt from the Start | All Programs |

    Visual Studio 2010 | Visual Studio Tools |Visual Studio Command Prompt

    (2010) menu

    2. Change the directory to C:\SPHOLS\SPLinqSolutionDemo

    cd C:\SPHOLS\SPLinqSolutionDemo

    3. spmetal.exe is a command line tool that can generate C# or VB.NET classes from a

    SharePoint site's list definitions. It is similar to wsdl.exe that generates a proxy from a

    Web Service's WSDL file.

    4. Run the following command to generate the LINQ proxy code.

    spmetal /web:http:// /namespace:Projects/code:Projects.cs

    5. Go back to Visual Studio 2010.6. Right-click on the SPLinqSolutionDemo project in the Solution Explorer and select

    Add | Existing Item.

    7. Browse to C:\SPHOLS\SPLinqSolutionDemo and select the Project.cs file that was

    generated when you ran spmetal.

    8. Right-click on the SPLinqSolutionDemo in the Solution Explorer and select Add

    Reference.

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    53/123

    49 www.microsoft.com/sharepoint

    9. Click on the Browse tab, navigate to the C:\Program Files\Common Files\Microsoft

    Shared\Web Server Extension\14\ISAPI folder, and select Microsoft.SharePoint.Linq.dll

    and select OK.

    Task 3: Write the code for the Visual WebPart User to access the list data.

    1. In Visual Studio 2010 open the SPLinqDemoPartUserControl.ascx file from the

    Solution Folder by double-clicking on it.

    2. Add the following markup to SPLinqDemoPartUserControl.ascx under the

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    54/123

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    55/123

    51 www.microsoft.com/sharepoint

    5. Add the following code to the SPLinqDemoPartUserControl.ascx.cs file (replace the

    existing Page_Load method).

    protectedvoid Page_Load(object sender, EventArgs e){

    ProjectsDataContext dc = newProjectsDataContext(SPContext.Current.Web.Url);

    EntityList Employees =dc.GetList("Employees");

    var empQuery = from emp in Employeeswhere emp.Project.DueDate 0)companyTable.deleteRow(companyTable.rows.length - 1);

    var row = new Array();var content;var cell;var tbo = document.createElement('tbody');// Loop for each contactfor (contactIndex = 0; contactIndex < contactCount;

    contactIndex++) {// For each contact create a row in the table

    row[contactIndex] = document.createElement('tr');// itemAt() retrieves the listitemvar contactLI = contacts.itemAt(contactIndex);// get_item() retrieves the listitem value// if the listitem value is from a lookup field we call

    get_lookupValue()var companyName =contactLI.get_item(ContactCompanyListField).get_lookupValue();

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    98/123

    94 www.microsoft.com/sharepoint

    var companyPhone =contactLI.get_item(CompanyPhoneField).get_lookupValue();

    var companyDesc =contactLI.get_item(CompanyDescriptionField).get_lookupValue();var companyContact = contactLI.get_item(ContactFirstNameField)

    + " " +

    contactLI.get_item(ContactLastNameField);var companyContactEmail =

    contactLI.get_item(ContactEmailField);// add the cells for the rowcell = document.createElement('td');content = document.createTextNode(companyName);cell.appendChild(content);row[contactIndex].appendChild(cell);cell = document.createElement('td');content = document.createTextNode(companyPhone);cell.appendChild(content);row[contactIndex].appendChild(cell);

    cell = document.createElement('td');content = document.createTextNode(companyDesc);cell.appendChild(content);row[contactIndex].appendChild(cell);cell = document.createElement('td');content = document.createTextNode(companyContact);cell.appendChild(content);row[contactIndex].appendChild(cell);cell = document.createElement('td');content = document.createTextNode(companyContactEmail);cell.appendChild(content);row[contactIndex].appendChild(cell);// Add the row to the table bodytbo.appendChild(row[contactIndex]);

    }// add the table body to the tablecompanyTable.appendChild(tbo);

    }

    5. Add the following JavaScript code within the Script block below the previous code.

    The ShowAddCompany() function finds the divAddCompanyElement (which well add later) and

    displays it using the ModalDialog.showModalDialog() method.

    /* Hide the modal dialog and display the updated UI */function onContactAdded() {

    HideAddCompany();}

    /* Show a modalDialog with the contents of divAddCompany */function ShowAddCompany() {

    var divAddCompany = document.getElementById("divAddCompany");

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    99/123

    95 www.microsoft.com/sharepoint

    // showModalDialog removes the element passed in from the DOM// so we save a copy and add it back latercopyOfAddCompanyForm = divAddCompany.cloneNode(true);

    divAddCompany.style.display = "block";

    var options = { html: divAddCompany, width: 200, height: 350,dialogReturnValueCallback: ReAddClonedForm };

    modalDialog = SP.UI.ModalDialog.showModalDialog(options);}

    /* Close the modalDialog */function HideAddCompany() {

    modalDialog.close();Initialize();

    }

    function ReAddClonedForm() {

    document.body.appendChild(copyOfAddCompanyForm);}

    6. Add the following JavaScript code within the Script block below the previous code.

    The AddCompany() function creates a new list item in the Company List.

    /* Called from the Add Company modal dialogCreates a list item in the Company List list and when that query isexecuted

    onCompanyAdded creates the contact list item. */function AddCompany() {

    var lici1 = new SP.ListItemCreationInformation();companyListItem = companyList.addItem(lici1);companyListItem.set_item(CompanyNameField,

    getTBValue("txtCompanyName"));companyListItem.set_item(CompanyPhoneField,

    getTBValue("txtPhoneNumber"));companyListItem.set_item(CompanyDescriptionField,

    getTBValue("txtDescription"));companyListItem.update();context.load(companyListItem);

    // Execute the query to create the company list// onCompanyAdded is our call back method called when the call to

    the server has completedcontext.executeQuery(onCompanyAdded, OnError);

    }

    7. Add the following JavaScript code within the Script block below the previous code.

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    100/123

    96 www.microsoft.com/sharepoint

    When the company list item is created we then create the lookup fields for the associatedcontacts. In the onContactAdded event handler the modal dialog is hidden.

    /* Called when AddCompany has finished executingNote we have to wait until completion because we need access tocompanyListItem

    to set the correct lookupId */function onCompanyAdded(args) {

    var lici = new SP.ListItemCreationInformation();var companyLookupField = new SP.FieldLookupValue();companyLookupField.set_lookupId(companyListItem.get_id());var contactListItem = contactsList.addItem(lici);contactListItem.set_item(ContactTitleField,

    getTBValue("txtContactTitle"));contactListItem.set_item(ContactFirstNameField,

    getTBValue("txtFirstName"));contactListItem.set_item(ContactLastNameField,

    getTBValue("txtLastName"));

    contactListItem.set_item(ContactEmailField,getTBValue("txtEMail"));

    contactListItem.set_item(ContactCompanyListField,companyLookupField);

    contactListItem.update();context.executeQuery(onContactAdded);

    }/* Hide the modal dialog and display the updated UI */function onContactAdded() {

    HideAddCompany();}

    8. Add the following JavaScript code within the Script block below the previous code.

    Helper functions / Error handler

    /* Error handler */function OnError(sender, args) {var spnError = document.getElementById("spnError");spnError.innerHTML = args.get_message();

    }/* Helper function - shortcut to the value property of a textbox */function getTBValue(elID) {

    var el = document.getElementById(elID);

    return el.value;}

    9. Add the following HTML code below the ending script block tag ()

    tblCompanyList is an empty table that our script dynamically adds rows/columns to for each

    contact/company.

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    101/123

    97 www.microsoft.com/sharepoint

    There is also a link to invoke ShowAddCompany() which will launch a modal dialog box.

    Company List


    Add a company

    Company Information

    Name

    Phone Number


    Description

    Contact Information

    Title

    First Name

    Last Name

    E-Mail


    The markup within divAddCompany will be displayed in a modal dialog that allows the user toinput data to create a new company/contact.

    Task 3: Deploy and test the web part.

    1. Right click on the ScriptOMExample project in the Solution Explorer and select

    Deploy.2. Add the web part to a web part page:

    Click the Edit button to put the page in edit mode.

    Click Insert

    Click Web Part

    Click Custom

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    102/123

    98 www.microsoft.com/sharepoint

    Click ScriptOMPart Title

    Click Add

    The rendered web part looks like this:

    3. To test the functionality of the web part click the Add a company link and fill out themodal form.

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    103/123

    99 www.microsoft.com/sharepoint

    4. Click the Add New Company button and the new company will be added to the listdynamically with no post backs.

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    104/123

    100 www.microsoft.com/sharepoint

    Exercise Summary

    In this walkthrough you built a Visual Web Part that contains ECMAScript that uses the

    SharePoint Client Object Model and the SharePoint Dialog Platform to show a modeldialog which gathers input for a new list item instance.

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    105/123

    101 www.microsoft.com/sharepoint

    Walkthrough 5: Creating and Using External Lists in SharePoint 2010

    Exercise Duration: 15 minutes

    Exercise Overview

    This example illustrates how to create a Business Connectivity Services (BCS) with an

    external content type using Visual Studio and utilize this content type in a SharePoint

    external list.

    Feature Overview

    An external list is a list based on data from an external system outside of SharePoint

    such as a CRM system or relational database.

    Task 1: Create a new Business Data Catalog Model project.

    1. Open Visual Studio 2010 from the Start | Programs | Visual Studio 2010

    menu.

    2. Create a new project by using File | New Project.

    3. Pick the SharePoint | 2010 templates.

    4. From the SharePoint | 2010 templates select the Business Data Connectivity

    Model template.

    5. Use BCSExample as the name.

    6. Set the location to be C:\SPHOLs.7. PressOKto create the project.

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    106/123

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    107/123

    103 www.microsoft.com/sharepoint

    Task 2: Extend the custom entity to allow updating.

    1. Click on the Entity1 | Methods area in the designer.

    2. This brings up the BDC Method Details window for Entity1.

    3. At the bottom of this window (you may need to scroll) find the Add a Method area.

    4. Open the combo box on the Add a Method area and select Create Updater Method.

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    108/123

    104 www.microsoft.com/sharepoint

    5. Select the newly created method called Update to retrieve the properties pane. ChangeIs Static = True.

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    109/123

    105 www.microsoft.com/sharepoint

    Task 3: Add the code to store list data in an in memory collection.

    1. Right click on Update and select View Code.

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    110/123

    106 www.microsoft.com/sharepoint

    2. Add the following variable to the Entity1Service class;

    static Dictionary EntityCollection = newDictionary();

    This variable will be used to hold the lists state information. A real world application

    would use a durable system such as a relational database instead.

    3. Replace the existing method implementations with the following code:

    public Entity1Service(){

    if (EntityCollection.Count == 0){

    // Create some test list items.Entity1 e1 = new Entity1();e1.Identifier1 = "e1";e1.Message = "e1 Item Data";EntityCollection.Add(e1.Identifier1, e1.Message);

    Entity1 e2 = new Entity1();

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    111/123

    107 www.microsoft.com/sharepoint

    e2.Identifier1 = "e2";e2.Message = "e2 Item Data";EntityCollection.Add(e2.Identifier1, e2.Message);

    }}publicstatic Entity1 GetEntityById(string id)

    {// Looks up the Entity information based on the id passedEntity1 entity1 = new Entity1();entity1.Identifier1 = id;entity1.Message = EntityCollection[id];return entity1;

    }publicstatic IEnumerable FindAllEntities(){

    // Iterates through our backingList entities = new List();foreach (String key in EntityCollection.Keys)

    { Entity1 entity1 = new Entity1();entity1.Identifier1 = key;entity1.Message = EntityCollection[key];entities.Add(entity1);

    }return entities;

    }

    publicstaticvoid Update(Entity1 inParameter1){

    // Updates the corresponding item in the collectionEntityCollection[inParameter1.Identifier1] = inParameter1.Message;

    }

    Task 4: Deploy and create an entity backed list based on this example.

    1. Right click on the BusinessDataCatalog1 project and select deploy.

    2. In the web browser click Site Actions -> View All Site Content -> Create.

    3. Beneath Custom Lists click External List.

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    112/123

    108 www.microsoft.com/sharepoint

    4. Specify CustomList as the name of the new list. Beneath Entity Type click the

    browse icon. Select the newly created Business Data Type in the list and click OK.

    The list will render the sample list items we added in the entitys constructor.

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    113/123

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    114/123

    110 www.microsoft.com/sharepoint

    Exercise Summary

    In this walkthrough you built an External Content Type in Visual Studio and deployed it

    to SharePoint 2010 for use in an External List.

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    115/123

    111 www.microsoft.com/sharepoint

    Walkthrough 6: Extending the SharePoint 2010 UI with Silverlight

    Exercise Duration: 20 minutes

    Exercise Overview

    This example shows how to create a Silverlight Application that uses the SharePoint

    Client Object model to render SharePoint list data. It also shows how to host that

    Silverlight Application in the Silverlight web part on SharePoint.

    Feature Overview

    The Silverlight Web Part allows developers and users to easily add Silverlight

    applications (*.XAP) to SharePoint sites. Client Object Model can be used in Silverlight to

    access SharePoint programmatically.

    Task 1: Create a Silverlight Application for the SharePoint Client Object Model.

    1. Open Visual Studio 2010 from the Start | Programs | Visual Studio 2010

    menu.

    2. Create a new project by using File | New Project.

    3. Pick the Visual C# | Silverlight templates.

    4. From the Visual C# | Silverlight templates select the Silverlight Application

    template.

    5. Use SPSilverlightExample as the name.6. Set the location to be C:\SPHOLs.

    7. PressOKto create the project.

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    116/123

    112 www.microsoft.com/sharepoint

    8. When the New Silverlight Application dialog appears, accept all the defaults by

    pressing OK.

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    117/123

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    118/123

    114 www.microsoft.com/sharepoint

    Task 2: Write code to access and render SharePoint List Data

    1. Open the Toolbox and expand Silverlight Controls.

    2. Drag a DataGrid control onto the Silverlight Designer.

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    119/123

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    120/123

    116 www.microsoft.com/sharepoint

    context.Load(context.Web);var projects = context.Web.Lists.GetByTitle("Projects");context.Load(Projects);

    var query = new Microsoft.SharePoint.Client.CamlQuery();var strQuery = "" +

    "" +"2008-01-1T00:00:00Z" +"" +"" +

    "" +"";

    query.ViewXml = strQuery;_projectItems = projects.GetItems(query);context.Load(_projectItems);context.ExecuteQueryAsync(OnRequestSucceeded, null);

    8. Add the following code inside of the Page class after the constructor:

    privatevoid OnRequestSucceeded(Object sender,ClientRequestSucceededEventArgs args){

    // this is not called on the UI threadDispatcher.BeginInvoke(BindData);

    }privatevoid BindData(){

    var list = new List();foreach (var li in _projectItems){

    list.Add(new Project{

    Title = li["Title"].ToString(),DueDate =

    Convert.ToDateTime(li["Due_x0020_Date"].ToString()),Description = li["Description"].ToString()

    });}dataGrid1.DataContext = list;}

    This code initializes the SharePoint Silverlight client object model context (ClientContext). It then

    gets a reference to the Projects list. Runs a simple CAML query against the list to pull all projects

    with a duedate greater than 1/1/2008. The results are converted into a list of Projects and bound

    to the Silverlight DataGrid control.

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    121/123

    117 www.microsoft.com/sharepoint

    Task 3: Deploy and Test using the SharePoint Silverlight web part.

    To deploy the solution to SharePoint the resulting .xap file needs to be in the C:\Program

    Files\Common Files\Microsoft Shared\Web Server

    Extensions\14\TEMPLATE\LAYOUTS\ClientBin folder.

    1. Right click on your project and select properties and select the Build tab.

    2. Change the output path to the following: C:\Program Files\Common Files\Microsoft

    Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\ClientBin.

    3. Build the solution and fix any typos that may have occurred.

    4. Add the SharePoint Silverlight web part to a web part page:

    Click the Edit button to put the page in edit mode.

    Click Insert

    Click Web Part

    Click Authoring

    Click Silverlight Web Part

    Click Add

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    122/123

    118 www.microsoft.com/sharepoint

    5. When prompted type in:/_layouts/ClientBin/SPSilverlightExample.xap

    The rendered web part looks like this:

  • 8/4/2019 Share Point 2010 Developer Evaluation Guide BETA Oct2010

    123/123

    Exercise Summary

    In this walkthrough you built a Silverlight application that accesses SharePoint lists using

    the Client Object Model.