Share Point 2010 Development for ASP.net Developers

  • Published on
    06-Apr-2018

  • View
    217

  • Download
    0

Embed Size (px)

Transcript

  • 8/3/2019 Share Point 2010 Development for ASP.net Developers

    1/27

    SharePoint 2010 Development for ASP.NET Developers

    Summary:

    This paper provides ASP.NET developers with helpful insight into SharePoint concepts from an ASP.NET

    developers perspective, making it easier to develop SharePoint applications. As a prerequisite, you should

    have a basic understanding of the differences between the SharePoint and ASP.NET platforms. These

    differences are explained well inSharePoint 2010: Developer Platform White Paper , and you should read

    and understand this paper before continuing.

    SharePoint is the fastest growing product in Microsofts history and its developer community is growing

    quickly. In the beginning, SharePoint was simply a collaboration platform, but it has evolved throughout

    the years to become what it is today; an integrated suite of server features including: content

    management, enterprise search, business connectivity services, and information management. With such

    powerful capabilities, the SharePoint application landscape ranges from simple web part solutions over

    business collaboration applications to sophisticated applications for integrating Line of Business (LOB)

    data.

    Although SharePoint is considered to be a development platform, it was hard for developers to quickly

    ramp up on SharePoint development because it required a deep knowledge of SharePoint architecture

    and infrastructure. Significant changes were made in SharePoint 2010 and Visual Studio 2010 to improve

    the development experience and some of the key concepts familiar to ASP.NET developers were

    introduced such as easy deployment and debugging of your SharePoint applications and designers for

    building different types of SharePoint customizations.

    SharePoint developer tooling has been greatly enhanced in Visual Studio 2010 and it includes many

    different templates for SharePoint projects and project items. Visual Studio provides developers with a

    familiar development environment and all of its benefits, such as IntelliSense and enhanced debugging. It

    makes it easier for ASP.NET developers who want to target the SharePoint platform. For more information,

    see the Glide Path for ASP.NET Developers on MSDN.

    SharePoint Overview

    There are three versions of SharePoint 2010:

    Microsoft SharePoint Foundation 2010: Microsoft SharePoint Foundation is the essential solution for

    organizations that need a secure, manageable, web-based collaboration platform. It serves as the basis for

    SharePoint server and offers out of the box elements such as blogs, wikis, team workspaces, and

    document libraries, providing users with the ideal way to share information and collaborate within acustomized website. In addition, it provides services such as Business Data Connectivity services to

    integrate external data, basic search services and workflow services.

    Microsoft SharePoint Server 2010: SharePoint Server 2010 is a superset of SharePoint Foundation 2010

    that adds enterprise content management and enterprise search capabilities as well as support for using

    InfoPath forms, Access services, social networking features, community features and Dashboards.

  • 8/3/2019 Share Point 2010 Development for ASP.net Developers

    2/27

    Although SharePoint Server 2010 is built largely on SharePoint Foundation 2010, its a separate product

    using it requires purchasing a license.

    SharePoint Online: A Microsoft-hosted version of SharePoint technology, this version lets both users and

    developers use SharePoints functionality without installing any on-premises SharePoint software.

    SharePoint provides great opportunities for application development at all levels of the software

    development stack. Being built upon ASP.NET and Windows Server platforms allows SharePoint to expose

    infrastructure features and inherent points of extensibility to application developers.

    SharePoint Developer Tools: SharePoint Designer and Visual

    Studio 2010

    SharePoint Designer and Visual Studio 2010 are two tools that can be used (together or separately) to

    customize or develop SharePoint solutions.

    SharePoint Designer 2010 is the tool of choice for the rapid development of SharePoint applications.

    Using SharePoint Designer, advanced users and developers alike can rapidly create SharePoint solutions in

    response to business needs. Advanced users can compose no-code solutions that encompass a variety of

    common scenarios, from collaborative sites and web publishing to Line-Of-Business data integration,

    business intelligence solutions, and human workflows, all leveraging the building blocks available in

    SharePoint in an easy to use environment. In addition, developers can use SharePoint Designer 2010 to

    get a quick start on SharePoint development projects. As SharePoint Designer works in a connected

    mode, meaning you must be connected to a SharePoint site, all SharePoint artifacts created by

    SharePoint Designer, such as SharePoint pages and content types, are stored in the content database.

    This concept might be new to ASP.NET developers and cause some confusion. To understand why

    SharePoint stores some artifacts in the database you need to understand the difference betweencustomized and uncustomized files in SharePoint.

    Uncustomized Files

    When you create a new SharePoint site in a site collection, SharePoint provisions instances of its files into

    a content database that resides on the file system. The files on the file system are called templates.Alone, they are not very useful because they are not mapped to any specific URL and therefore cannot be

    directly accessed with a browser. The instances of the files in the content database are merely added to

    the site. When ASP.NET receives a request for a file, it first locates it in the content database. The entry in

    the content database tells ASP.NET that the file is actually based on a file on the file system and, therefore,

    ASP.NET retrieves the source of the file on the file system when it constructs the page.

    This is how most files start in a SharePoint site. They are called uncustomizedfiles files that reside onthe file system and not in the content database. The only thing that resides in the content database is an

    instance of the uncustomized file that registers the file in the site.

    One thing to note is that there can be multiple instances of a file in a site collection's content database, or

    content databases, all referencing the same file. This is how the master page included with

  • 8/3/2019 Share Point 2010 Development for ASP.net Developers

    3/27

    SharePoint, v4.master, is implemented. Every SharePoint site starts with an uncustomized instance of the

    v4.master page. If an environment contained 100 SharePoint sites created with the Blank Site template,

    and no customizations had been made, there will be 100 uncustomized instances of the v4.master page in

    the various content databases, yet there would be only a single v4.master page on the file system.

    Customized Files

    The other type of file is a customizedfile. A customized file is one in which the source of the file livesexclusively in the site collection's content database. How can a file become customized? If you modify the

    file in any way through the SharePoint API, the source of the new page is saved in the content database.

    This includes SharePoint Designer 2010, which uses the SharePoint API via RPC and web service calls to

    change files in sites. When the file is requested, ASP.NET first finds the file in the content database. The

    entry in the database tells ASP.NET whether the file is customized or uncustomized. If it is customized, it

    contains the source of the file which is used by ASP.NET in the page contraction phase.

    A file can start as an uncustomized instance and become customized. For example, after a site has been

    created, someone can open the site in SharePoint Designer 2010 and make a few changes to the

    v4.master page. When the file is saved, it changes from uncustomized to customized. This system enables

    SharePoint to store only a single instance of a file template on the file system regardless of how many

    sites implement it, while at the same time enabling site-by-site customizations of the file.

    Andrew Connell has written a great article for Windows SharePoint Services V3 which can be found

    here: http://msdn.microsoft.com/en-us/library/cc406685.aspx. The concept of customized vs.

    uncustomized files hasnt changed in SharePoint Foundation 2010 or SharePoint Server 2010 so the

    content of that article is still valid.

    Visual Studio 2010

    Visual Studio 2010 uses a different approach than traditional SharePoint design tools. First of all, VisualStudio targets developers writing code as opposed to SharePoint Designer which targets the Power User

    or breadth developer. Secondly, Visual Studio works in a disconnected mode (Note: Visual Studio 2010

    must be installed on the same machine as SharePoint 2010) which means that the project output, such as

    dlls, files, etc., is stored on disc and packaged into a SharePoint solution package (WSP) file

    (seeDeploying Solutions to SharePoint). This enables full application lifecycle management capabilities,

    such as source control and daily builds.

    Because Visual Studio 2010 offers visual designers, packaging and deployment support, project and item

    templates, and project and tool extensibility, you might be wondering when to use which tool. In general,

    use Visual Studio 2010 if you:

    y Are a developer.y Need to use Application Lifecycle management for your SharePoint solution.y Have more complex requirements for your SharePoint solutions which require code.y Visual Studio is your preferred development environment.

    Also, there are some SharePoint development tasks which can be accomplished only in Visual Studio. Use

    Visual Studio if you want to create:

  • 8/3/2019 Share Point 2010 Development for ASP.net Developers

    4/27

    y Site definitionsy List definitionsy Custom web partsy Application pagesy BDC models that use a .NET connector

    o Foreign key-less associations between two external content typesy Code-based workflowsy User controlsy Event receiversy Feature event receivers

    Although SharePoint Designer and Visual Studio have different target audiences and development

    approaches, they work well together. For example, SharePoint Designer offers graphical designers for

    creating SharePoint pages and lists whereas Visual Studio only provides an XML editor for list templates.

    Lets assume you need to build a simple SharePoint library solution containing a web part, a SharePoint

    list and an event receiver. Because the web part and the event receiver require code, you would develop

    those in Visual Studio, but what about the list? As mentioned earlier, Visual Studio provides only an XML

    editor for creating lists. To build a list using the XML editor you need to understand CAML (CollaborativeApplication Markup Language) which is used by SharePoint to define lists, sites templates and definitions.

    A good solution to this problem is to take advantage of the List Designer in SharePoint Designer which

    doesnt require a knowledge of CAML. Once you have designed the list in SharePoint Designer, you can

    save the entire SharePoint site which contains the list as a WSP (seeWeb Templates for more

    information) and then import the WSP into Visual Studio. (See Importing Items from an Existing

    SharePoint Site.) Now, you can add the web part and the event receiver to the list from the WSP and

    deploy all of the contents together in the library solution.

    SharePoint Extension points

    There are many different ways to customize and extend SharePoint. The following sections highlight anumber of these different SharePoint extension points.

    SharePoint Sites

    Often, it is hard to understand the difference between a SharePoint site and an ASP.NET site. From an

    ASP.NET developers point of view, a web site is a group of related web pages hosted by an HTTP server

    on the World Wide Web or on an intranet site. The same applies to SharePoint sites. Most web sites have

    a home page as their starting point. The home page is interconnected with other pages by using

    hyperlinks. You can use top-level sites and subsites. A top-level site is a web site at the top of thehierarchy in a site collection from which you can manage site collection features. A top-level site can have

    one or more subsites, and subsites can have other subsites. A subsite is a complete web site stored in a

    named subdirectory of the top-level web site. Each subsite can have administration, authoring, andbrowsing permissions that are independent from the top-level web site and other subsites. This strategy

    divides site content into distinct, separately manageable sites. The entire structure of a top-level web site

    and all of its subsites is called a web site collection, a set of web sites that have the same owner andshare administration settings. Each site collection contains a top-level site, can contain one or more

    subsites, and may have a shared navigation structure. Site collections can also be seen as information

    boundaries in SharePoint because content isnt typically shared between site collections.

  • 8/3/2019 Share Point 2010 Development for ASP.net Developers

    5/27

    This hierarchy enables users to have a main working site for the entire team, plus individual working sites

    or shared sites for side projects. Top-level web sites and subsites allow different levels of control over the

    features and settings for sites. The administrator of the Web site controls the ability to create, access, and

    contribute content to a Web site.

    SharePoint Lists and Libraries

    A list in SharePoint is a collection of information that is shared with team members. For example, you can

    create a sign-up sheet for an event, or you can create tasks that you need to track. You can use the lists

    that come with SharePoint as-is, you can change the lists, delete lists that you don't need, or create new

    custom lists. SharePoint provides list templates for links, announcements, contacts, events, tasks, and

    issues. You can also add views to lists. For example, you can create a view on a task list that only shows

    tasks that are active. When you create your own lists, you can base them on the designs used for the

    built-in lists, or you can create custom lists from scratch. The following is an example of a task list.

  • 8/3/2019 Share Point 2010 Development for ASP.net Developers

    6/27

    Find more information about working with SharePoint lists from an end user perspective and from

    a developer perspective.

    SharePoint libraries are technically lists for collections of files, such as Word documents, Excel documents,

    images etc., that are shared with team members on SharePoint. For example, you can create a library of

    common documents for a project, and team members can use their Web browsers to find the files, read

    them, and make comments. Users with Microsoft Office can check out and edit the files as if they resided

    on a local or network drive.

    Application Pages and Site Pages

    SharePoint Foundati...