Gettingstarted With Share Point 2010

  • Upload
    ozamaro

  • View
    217

  • Download
    0

Embed Size (px)

Citation preview

  • 8/3/2019 Gettingstarted With Share Point 2010

    1/30

    Getting Started with SharePoint 2010

  • 8/3/2019 Gettingstarted With Share Point 2010

    2/30

    Getting Started with SharePoint 2010

    Table of Contents

    Getting Started with SharePoint 2010 .................................................................................... 1

    Getting Started .............................................................................................................................................................. 2

    Lab Setup Instructions ................................................................................................................................................... 3

    Exercise 1 Creating a Site Collection in SharePoint Central Administration .................................................................. 4

    Exercise 2 Working with the SharePoint 2010 Ribbon and In-place Editing ................................................................. 7

    Exercise 3 Working with PowerShell Scripts ................................................................................................................ 15

    Exercise 4 Programming with the SharePoint 2010 Object Model ............................................................................. 21

  • 8/3/2019 Gettingstarted With Share Point 2010

    3/30

    Getting Started with SharePoint 2010

    Page 1 of 28

    Getting Started with SharePoint 2010

    Objectives In this lab you will begin your work with SharePoint 2010 and become familiarwith the Virtual Machine (VM) that you will be using. You will get experience

    working with the SharePoint 2010 Central Administration site as well asworking with a standard team site. This will allow you to experience the new

    user interface concepts introduced in SharePoint 2010 such as the server-side

    ribbon and in-place item editing. You will also get a chance to write and test C#

    code using the SharePoint Foundation 2010 object model. Note that we are

    purposefully delaying any work with the new Visual Studio 2010 Tools for

    SharePoint 2010 until the next lab because this new tool set is the focus of the

    next lecture. At the end of this lab you will also get some hands-on experience

    working with PowerShell and the new SharePoint 2010 PowerShell Snap-in.

    Estimated Time to

    Complete This Lab

    45 Minutes

    Computers used in this

    Lab

    Additional Resources

    demo2010

    The password for the Contoso/Administrator account on all computers in this

    lab is: pass@word1

    This lab includes the following additional resources:

    StarterFiles

    C:\Student\Labs\01_Roadmap\StarterFiles Files that can beused to help

    complete the

    labs.

    Source

    Code

    C:\Student\Labs\01_Roadmap\Solution Completed lab

    source code in C#

    for Lab01_OM.

    Resources C:\Student\Presentations\01_Roadmap Supporting

    presentations for

    the topics in this

    lab.

    .

  • 8/3/2019 Gettingstarted With Share Point 2010

    4/30

    Getting Started with SharePoint 2010

    Page 2 of 28

    Getting Started

    ScenarioThis Hands-On Lab contains a number of additional resources in fixed locations. By default, it is assumed that the

    base HOL directory is C:\Student and that the labs and additional resources are located under this directory.

    The default working folder for this lab is C:\Student\Labs\01_Roadmap.

    Copying code samples from Word document

    Copying and pasting code from this Word document to Visual Studio is only safe for the sections of formatted

    code, e.g.:

    Console.WriteLine("This is safe code!");

    Code not in these sections may contain Unicode or other invisible characters that are not valid XML or C#/VB code,

    e.g.:

    Console.WriteLine(This is NOT safe code !!);

  • 8/3/2019 Gettingstarted With Share Point 2010

    5/30

    Getting Started with SharePoint 2010

    Page 3 of 28

    Lab Setup Instructions

    ScenarioIn the lab setup you will execute a PowerShell script that will create a new SharePoint site collection.

    Tasks Detailed Steps

    Complete the following

    task on:

    demo2010

    a. Start the Virtual Machine in Hyper-V.b. Log on to the Virtual Machine as the local administrator with a user name of

    Contoso\Administrator and a password ofpass@word1.

    c. Open Windows Explorer and browse to the locationC:\Student\Labs\01_RoadMap, in the folder double click SetupLab01.bat.

    d. Verify the site created successfully message, and then press a key to close theprompt.

    e. The setup script launches a PowerShell script that creates a sample SharePointsite at the location http://intranet.contoso.com/sites/Lab01that you will use in

    the next exercises.

  • 8/3/2019 Gettingstarted With Share Point 2010

    6/30

    Getting Started with SharePoint 2010

    Page 4 of 28

    Exercise 1

    Creating a Site Collection in SharePoint Central

    Administration

    ScenarioIn this exercise you will review an existing SharePoint site collection and then create a new SharePoint site

    collection using the SharePoint Central Administration site

    Tasks Detailed Steps

    Complete the following

    task on:

    Paris

    1. Explore the CentralAdministration site

    a. Click Start | All Programs | Microsoft SharePoint 2010 Products | SharePoint2010 Central Administration.

    Internet Explorer starts and the SharePoint Central Administration Site appears.

    You will now review some of the features in this site.

    b. On the left-hand side of the screen, in the Quick Launch bar, click SystemSettings.The System Settings page appears. Review the system settings available on this

    page.

    c. On the Quick Launch bar, click Monitoring.The Monitoring page appears. Review the monitoring options available on this

    page.

    d. On the Quick Launch bar, click Application Management.The Application Management page appears. Review the options available on this

    page.

    e. In the Site Collections section, click View all site collections.A list of site collections for the selected Web Application appears.

    f. Choose http://intranet.contoso.com from the Web Application drop down.g. In the URL list on the left hand side of the screen click /sites/broadcast and

    review the site details in the right hand pane. Leave Internet Explorer running;

    you will use it in the next task.

    Complete the following

    task on:

    Denver

    2. Create a new sitecollection

    Note: In this task you will create a new site collection and browse to the newly

    created site. This site will be used in later exercises.

    a. On the Quick Launch bar, click Application Management.The Application Management page appears.

    b. In the Site Collections section, click Create site collections.The Create Site Collection page appears.

    c. In the Title field, type Contoso Sales Sited. In the Description field, type My first SharePoint 2010 site collection e. In the URL field, type http://intranet.contoso.com/sites/Lab01Af. In the Template Selection field, on the Collaboration tab, click Team Site.g. In the Primary Site Collection Administrator User Name field, type

    CONTOSO\Administrator

    h. In the Secondary Site Collection Administrator User Name field, leave the value

  • 8/3/2019 Gettingstarted With Share Point 2010

    7/30

    Getting Started with SharePoint 2010

    Page 5 of 28

    Tasks Detailed Steps

    blank.

    i. In the Quota Template dropdown list, select the value No Quota.

    Figure 1 - Site Creation Details

    j. Click OK. The new site provisioning process begins.When the site collection provisioning process has completed a confirmation page

    is provided with a hyperlink to navigate to the new site.

    Figure 2 - Site Creation Confirmation

    k. On the Top-Level Site Successfully Created page click thehttp://intranet.contoso.com/sites/Lab01Ahyperlink to navigate to the new site

    collection.

    The new site collection opens in a new window. Leave the new site collection

    window open; you will use it in the next exercise.

  • 8/3/2019 Gettingstarted With Share Point 2010

    8/30

  • 8/3/2019 Gettingstarted With Share Point 2010

    9/30

    Getting Started with SharePoint 2010

    Page 7 of 28

    Exercise 2

    Working with the SharePoint 2010 Ribbon and In-place

    Editing

    ScenarioIn this exercise you will work with the site collection created in Exercise 1. You will:

    Experience the new paradigm for in-place editing by adding and viewing list items. Work with a Web Part page so you can experience how the SharePoint 2010 user interface has changed

    the way users manage Web Parts.

    Tasks Detailed Steps

    Complete the following

    task on:

    Paris

    1. Modifying the Homepage content

    Note: In this task you will modify text and the default image on the home page.

    a. Ensure you are viewing the Contoso Sales Site that you created in the previousexercise.Note that the home page is not default.aspx but rather a wiki page named

    Home.aspx. This is a wiki page located inside a library named SitePages.

    b. Near the top left of the page, click the Site Actions menu, and then click EditPage.

    The site enters edit mode with the cursor indicating the current insert point.

    Figure 3 - The Site Actions menu

    c. Select the text Welcome to your site! and then press [Delete]. Then typeContoso Sales Site.

    Note the ribbon commands update to provide contextual commands editing

    text.

  • 8/3/2019 Gettingstarted With Share Point 2010

    10/30

    Getting Started with SharePoint 2010

    Page 8 of 28

    Tasks Detailed Steps

    Figure 4 - The Ribbon Control

    d. Select the text Contoso Sales Site and use the font toolbar to change the font to36pt and Font Color Red.

    e. Click the graphic on the right-hand side of the page and press [Delete].f. On the ribbon, under Editing Tools, click the Insert tab.g. Click the Picture button.

    The Add Picture dialog box appears. Note that the Add Picture dialog box

    enables you to select an image which will be automatically uploaded and stored

    in a document library named Site Asset Library.

    h. Click Browse and navigate the following file:C:\Student\Labs\01_Roadmap\starterfiles\FrontPage.jpgthen click Open.

    i. On the Select Picture dialog, click OK.j. On the ribbon, under Editing Tools, click the Format Text tab.k. On the ribbon, click Save & Close.

    Figure 5 - The Edited Page

    Complete the following

    task on:

    Denver

    1. Modifying SiteSettings

    In this task you will explore settings available for the site from the Site Actions menu.

    a. Click the Site Actions menu, and then click Site Settings.This page contains links to numerous administrative features.

  • 8/3/2019 Gettingstarted With Share Point 2010

    11/30

    Getting Started with SharePoint 2010

    Page 9 of 28

    Tasks Detailed Steps

    Figure 6 - Site Settings

    b. In the Look and Feel section, click Title, description and icon.The Title, Description and Appearance page appears. This page enables you to

    change the title and description you entered in the previous exercise.

    c. In the Logo URL and Description section, in the URL textbox, type the following:/_layouts/images/unknownperson.png

    d. Click OK.The Site Settings page appears. The image in the ribbon has been updated.

  • 8/3/2019 Gettingstarted With Share Point 2010

    12/30

    Getting Started with SharePoint 2010

    Page 10 of 28

    Tasks Detailed Steps

    2. Using the server-sideribbon

    Note: In this task you will use the server-side ribbon and review the contextual

    controls that appear for items that are selected.

    a. On the Quick Launch bar, in the Lists section, click Tasks.The task list is displayed, and is currently empty. The tasks list has an associated

    server-side ribbon with tabs including Browse, Share & Track, Items and List.b. On the Ribbon, click List.

    The ribbon displays contextual controls for the List task.

    Figure 7 - List Ribbon

    c. On the Ribbon, click Items.The ribbon displays contextual controls for the Items task.

    Figure 8 - Items Ribbon

    3. Creating a Task and adependent Task item

    Note: In this task you will use the new dialog platform to create a task and a

    dependent task.

    a. Click the dropdown arrow on the New Item button, and then click Task.The Tasks - New Item dialog box displays.

  • 8/3/2019 Gettingstarted With Share Point 2010

    13/30

    Getting Started with SharePoint 2010

    Page 11 of 28

    Tasks Detailed Steps

    Figure 9 - Tasks - New Item Dialog

    b. In the Title textbox, type Learn how to develop on SharePoint 2010.c. In the Priority dropdown list, select (1) High.d. In the Status dropdown list, select In Progress.e. In the % Complete textbox, type 2.f. In the Assigned to textbox, type Contoso\Administratorg. In the Description textbox, type Find out how to develop useful solutions.h. In the Start Date textbox, select date few days from today.i. In the Due Date textbox, select date later than in start date.j. On the toolbar, click Save.

    The newly created task appears in the list.

    k. Click the dropdown arrow on the New Item button, and then click Task.l. In the Title textbox, type Develop Solutions on SharePoint 2010.m. In the Predecessors list box, select how to develop on SharePoint 2010 and click

    Add.

    n. In the Priority dropdown list, select (1) High.o. In the Status dropdown list, select Not Started.p. In the % Complete textbox, type 0.q. In the Assigned to textbox, type Contoso\Administratorr. In the Description textbox, type Begin developing solutions on SharePoint 2010.s. In the Start Date textbox, select date which is few days from todayt. Leave the Due Date textbox blank.u. On the toolbar, click Save.

    The newly created task appears in the list.

  • 8/3/2019 Gettingstarted With Share Point 2010

    14/30

    Getting Started with SharePoint 2010

    Page 12 of 28

    Tasks Detailed Steps

    Figure 10 - List of Tasks

    4. Editing a Task Note: In this task you will observe the in-place editing behavior as you edit a task.a. Point to the Learn how to develop on SharePoint 2010 task, and then click the

    dropdown arrow that appears.

    Figure 11 - In-Place Editing

    b. Click Edit Item.Note that no page post backs occur; the task can be edited in-place.

    c. Modify the % Complete textbox so that it reads 5d. Click Save.

    5. Add a Web Part to apage

    Note: In this task you will add a Web Part to a Web Part page using the new user

    interface for managing Web Parts.

    a. In Internet Explorer type following URL:http://intranet.contoso.com/sites/Lab01A/sitepages/home.aspx

    This URL opens a Web Part page that does not have a direct link on a newly

    created site. Note the ribbon options that are available for this Web Part page.

    b. Choose Edit page from Site Actionsc. Note that the ribbon on this page has three tabs titled Browse, Page and Edit

    Tools. Click on each of these tabs and see how the contextual controls on the

    ribbon change for each of these tabs.

  • 8/3/2019 Gettingstarted With Share Point 2010

    15/30

    Getting Started with SharePoint 2010

    Page 13 of 28

    Tasks Detailed Steps

    d. Click on the Insert tab that takes you into the mode for adding, modifying anddeleting Web Parts from the page

    e. Delete the Shared Documents Web Part in the zone by clicking on the Deletecommand on the Web Part menu.

    Figure 12 - Deleting a Web Part

    f. Click the OK button on the Message from webpage dialog.g. Place your cursor below the Contoso Sales Site messageh. On the ribbon, in the Page Tools section, click Insert.i. Click on the Web Part button which is shown below.

    Figure 13 - Deleting a Web Part

    j. At this point you should see the new SharePoint 2010 UI for adding new WebParts to a page. Select Lists and Libraries in the left-hand section and then select

    Tasks in the right-hand section. Once you have select the Tasks list, make sure

    the drop-down box on the far right bottom (shown below) has the Right zone

    selected, then click the Add button to add the Web Part instance to the page.

  • 8/3/2019 Gettingstarted With Share Point 2010

    16/30

    Getting Started with SharePoint 2010

    Page 14 of 28

    Tasks Detailed Steps

    Figure 14- Web Part Interface

    k. Save your changes by selecting the Save & Close button on the ribbon. Now thatyou have completed this exercise, you should have a page that looks like the one

    shown below.

  • 8/3/2019 Gettingstarted With Share Point 2010

    17/30

  • 8/3/2019 Gettingstarted With Share Point 2010

    18/30

    Getting Started with SharePoint 2010

    Page 16 of 28

    Tasks Detailed Steps

    d. At the PowerShell command prompt, type the following text:Get-ChildItem

    e. Press [Enter].PowerShell lists the scripts contained in the current location.

    f. At the PowerShell command prompt, type the following text:Notepad Hello.ps1

    g. Press [Enter].Review the contents of the hello.ps1 PowerShell file.

    h. Close Notepad.i. At the PowerShell command prompt, type the following text:

    .\Hello.ps1

    j. Press [Enter].The script runs and a simple message is output to the PowerShell console.

    PowerShell Execution Policy

    If the PowerShell scripting support on the machine has the

    execution policy ofrestricted, the script will not run. If the

    execution policy has been changed to unrestricted, the

    console will prompt you whether to run the script or not.

    When writing and testing PowerShell scripts, it is easiest to

    change the execution policy to Bypass so that scripts can

    freely run without any user prompts. If your machine will

    not execute the .\Hello.ps1 script use the following

    instruction at the PowerShell command prompt:

    Set-ExecutionPolicyByPass

    k. Leave the PowerShell console open; you will use it in a later task.

    2. Using the PowerShellIntegrated Scripting

    Environment (ISE)

    Note: In this task you will use the Integrated Scripting Environment to edit and

    execute PowerShell scripts.

    a. Click Start | All Programs | Accessories | PowerShell | Windows PowerShell ISE The PowerShell Integrated Scripting Environment starts.

  • 8/3/2019 Gettingstarted With Share Point 2010

    19/30

    Getting Started with SharePoint 2010

    Page 17 of 28

    Tasks Detailed Steps

    Figure 16 - Starting Windows PowerShell ISE

    b. Click the File menu, then click Open.c. Browse to the file C:\Student\Labs\01_Roadmap\Powershell\Hello.ps1and

    click Open.

    The Hello.ps1 file appears at the top of the screen.

    Figure 17 - The PowerShell ISE

    d. Click the Debug menu option and review the options, then click Run/Continue.e. In the Script pane at the top of the Integrated Scripting Environment edit the

    script so that it looks as follows:

    $HelloMessage = "Sample Message"

  • 8/3/2019 Gettingstarted With Share Point 2010

    20/30

    Getting Started with SharePoint 2010

    Page 18 of 28

    Tasks Detailed Steps

    Write-Host "-----------------------------------"

    Write-Host "Hello World of Powershell Scripting"

    Write-Host "Host name: "$(Get-Item env:\computerName).value

    Write-Host $HelloMessage

    Write-Host "-----------------------------------"

    3. Debugging aPowerShell script in

    the Integrated

    Scripting

    Environment

    Note: In this task you will single step through a PowerShell script.

    a. In the Script pane, click in the first line of the Hello.ps1 script.b. Click the Debug menu, and click Toggle Breakpoint.c. Click the Debug menu, and click Run/Continue.d. Click OK if asked to save the script first.

    The code execution pauses at the point the breakpoint was set.

    Figure 18 - PowerShell Breakpoint

    e. Click the Debug menu, and click Step Into to step through each of the remaininglines of code. Note that you can also use F11.4. Using the PowerShell

    Console to load the

    SharePoint Snap-in

    Note: In this task you will prepare the PowerShell environment to run SharePoint

    scripts.

    a. In the PowerShell command prompt that you left open in Task 1, type thefollowing:

    Notepad LoadSharePointSnapin.ps1

    b. Press [Enter].Review the code and note the call to the Add-PSSnapin cmdlet. This loads the

    snap-in for SharePoint 2010 named Microsoft.SharePoint.PowerShell.

    c. Close Notepad.d. At the PowerShell command prompt, type the following text:

    .\LoadSharePointSnapin.ps1

    e. Press [Enter].At this point the PowerShell commagnds for SharePoint have been enabled.

    f. At the PowerShell command prompt, type the following text:Get-Command -PSSnapin Microsoft.SharePoint.PowerShell

  • 8/3/2019 Gettingstarted With Share Point 2010

    21/30

    Getting Started with SharePoint 2010

    Page 19 of 28

    Tasks Detailed Steps

    g. Press [Enter].A list is returned of all the commands supported by SharePoint.

    h. At the PowerShell command prompt, type the following text:Get-Command -PSSnapin Microsoft.SharePoint.PowerShell -Verb Get

    i. Press [Enter].A list is returned of all of the Get commands supgeported by SharePoint.

    j. At the PowerShell command prompt, type the following text:Get-Command -PSSnapin Microsoft.SharePoint.PowerShell >SP2010Cmdlets.txt

    k. Press [Enter].This time the full list of commands are piped to a new text file.

    l. At the PowerShell command prompt, type the following text:Notepad SP2010Cmdlets.txt

    m. Press [Enter].The commands are opened in notepad.

    n. Close Notepad.5. Using the PowerShell

    Console to create a

    SharePoint site

    Note: In this task you will use the PowerShell console to create a SharePoint site.

    a. At the PowerShell command prompt, type the following text:Get-Help New-SPSite

    b. Press [Enter].The details for the New-SPSite command are shown. You will now create a

    SharePoint site using the New-SPSite object.

    c. At the PowerShell command prompt, type the following text:new-spsite -URL http://intranet.contoso.com/sites/Lab01C -OwnerAlias

    Contoso\Administrator -Template STS#1 -Name Lab01C

    d. Press [Enter].When the PowerShell script completes, open Internet Explorer and review the

    newly created site at http://intranet.contoso.com/sites/Lab01c.

  • 8/3/2019 Gettingstarted With Share Point 2010

    22/30

    Getting Started with SharePoint 2010

    Page 20 of 28

    Tasks Detailed Steps

    6. Using a PowerShellScript to create a

    SharePoint site

    Note: In this task you will use and existing PowerShell script to create a SharePoint

    site.

    a. At the PowerShell command prompt, type the following text:Notepad CreateContosoSite.ps1

    b. Press [Enter].Review the details in the script file.

    c. Close Notepad.d. At the PowerShell command prompt, type the following text:

    .\CreateContosoSite.ps1 Lab01D

    e. Press [Enter].When the PowerShell script completes a success message is returned.

    f. Type Exit and press [Enter] to leave PowerShell.g. Type Exit and press [Enter] to close the command Prompt.h.

    Use Internet Explorer to open the sitehttp://intranet.contoso.com/sites/Lab01d

    i. Verify the newly created site.

    http://intranet.contoso.com/sites/Lab01dhttp://intranet.contoso.com/sites/Lab01dhttp://intranet.contoso.com/sites/Lab01d
  • 8/3/2019 Gettingstarted With Share Point 2010

    23/30

    Getting Started with SharePoint 2010

    Page 21 of 28

    Exercise 4

    Programming with the SharePoint 2010 Object Model

    ScenarioIn this exercise you will create a new console application that uses the SharePoint Foundation 2010 object model

    to create new lists and add items to a SharePoint 2010 site.

    Tasks Detailed Steps

    1. Configure a C#Console Project to

    use the SharePoint

    Object Model

    Complete the following

    task on:

    demo2010

    Note: In this task you will configure a Visual Studio 2010 C# project to use the

    SharePoint object model.

    a. Open Internet Explorer and navigate to the sitehttp://intranet.contoso.com/sites/lab01/.

    This blank site was created in the Lab Setup. This is a team site.

    b. Click Start | All Programs | Microsoft Visual Studio 2010| Microsoft VisualStudio 2010.

    c. On the Start page, in the Projects section, click New Project.

    Figure 19 - Visual Studio Start Page

    d. Click the Target Framework dropdown at the top of the page and select .NETFramework 3.5.

    This step enables you to add references to the SharePoint object library.

  • 8/3/2019 Gettingstarted With Share Point 2010

    24/30

    Getting Started with SharePoint 2010

    Page 22 of 28

    Tasks Detailed Steps

    SharePoint 2010 is based on .Net 3.5 and not version 4.0.

    e. In the Installed Templates section, in the Visual C# group, click Windows, thenclick Console Application.

    f. In the Name textbox, type Lab01_OMg. In the Location textbox, type c:\Student\Labs\01_Roadmap and then click OK.

    Figure 20 - Template Selection

    h. In the Solution Explorer window, right-click Lab01_OM, and then clickProperties.

    i. Click the Build tab.j. In the Platform target dropdown list, select x64 or Any CPU.

    Figure 21 - Setting Platform Target x64

    k. In the Solution Explorer window, right-click References, and then click AddReference.

    l. Click the Browse tab, and then browse to the following location:C:\Program Files\Common Files\Microsoft Shared\Web Server

  • 8/3/2019 Gettingstarted With Share Point 2010

    25/30

    Getting Started with SharePoint 2010

    Page 23 of 28

    Tasks Detailed Steps

    Extensions\14\ISAPI.

    m. Click Microsoft.SharePoint.dll and then click OK.

    Figure 22 - Setting a Reference to Microsoft.SharePoint.dll

    n. In the Solution Explorer window, right-click References, and then click AddReference.

    o. Click the .NET tab.p. Click System.Web and then click OK.

    2. Enabling theDeveloper

    Dashboard in a

    Console Application

    Note: In this task you will modify the code in the Console application to enable the

    Developer Dashboard on a SharePoint Site. You will then alter the code and disable

    the dashboard.

    a. In the Solution Explorer window, double-click Program.cs.b. Paste the following code to replace the code in Program.cs :

    using System;using Microsoft.SharePoint;

    using Microsoft.SharePoint.Administration;

    namespace Lab01_OM {

    class Program {

    static void Main() {

    SPWebService contentService = SPWebService.ContentService;

    SPDeveloperDashboardSettings developerDashboard =

  • 8/3/2019 Gettingstarted With Share Point 2010

    26/30

    Getting Started with SharePoint 2010

    Page 24 of 28

    Tasks Detailed Steps

    contentService.DeveloperDashboardSettings;

    developerDashboard.DisplayLevel = SPDeveloperDashboardLevel.On;

    developerDashboard.Update();

    Console.WriteLine("Developer Dashboard updated.");

    }

    }

    }

    Note: if yourcontentService variable turns out to be null, you have to check your

    project properties. Good chance you havent selected the x64 platform.

    c. Press [CTRL] + [F5] to run the console application.d. Press a key to close the console application.e. Return to the Internet Explorer window that you left open in Task 1 at the

    following site:

    http://intranet.contoso.com/sites/lab01/default.aspx

    f. Press [F5] to refresh Internet Explorer.Scroll to the bottom of the page, and note that the developer dashboard isenabled.

    Figure 23 - Developer Dashboard Page Footer

    g. In Visual Studio, update the single line of code so that the DisplayLevel value is set to Off. The code should look as follows:

    using System;

    using Microsoft.SharePoint;

    using Microsoft.SharePoint.Administration;

    namespace Lab01_OM {

    class Program {

    static void Main() {

    SPWebService contentService = SPWebService.ContentService;

    SPDeveloperDashboardSettings developerDashboard =

    contentService.DeveloperDashboardSettings;

  • 8/3/2019 Gettingstarted With Share Point 2010

    27/30

    Getting Started with SharePoint 2010

    Page 25 of 28

    Tasks Detailed Steps

    developerDashboard.DisplayLevel = SPDeveloperDashboardLevel.Off;

    developerDashboard.Update();

    Console.WriteLine("Developer Dashboard updated.");

    }

    }

    }

    h. Press [CTRL] + [F5] to run the console application.i. Press any key to close the console application.j. Return to Internet Explorer.k. Press [F5] to refresh Internet Explorer.

    Scroll to the bottom of the page, and note that the developer dashboard is now

    disabled.

    3. Using the SPSiteobject in a Console

    application

    Note: In this task you will write code that programs against the top-level site you

    created at the beginning of this exercise. In this task you will:

    Modify the Main method in program.cs to create a new SPSite object to programagainst the new site collection.

    Structure your code inside a using construct so that your code makes an implicitcall to the Dispose method to prevent leakage.

    Obtain a reference to the SPWeb object for the top-level site and print the Titleproperty of the site to the console window.

    a. Return to Visual Studio.b. In the Solution Explorer window, double-click Program.cs.c. Paste the following code to replace the code in Program.cs :

    using System;

    using Microsoft.SharePoint;

    using Microsoft.SharePoint.Administration;

    namespace Lab01_OM

    {

    class Program {

    static void Main()

    {

    string targetSiteUrl = "http://intranet.contoso.com/sites/Lab01A";

    using (SPSite siteCollection = new SPSite(targetSiteUrl))

    {SPWeb site = siteCollection.RootWeb;

    Console.WriteLine(site.Title);

    Console.ReadLine();

    }

    }

    }

    }

  • 8/3/2019 Gettingstarted With Share Point 2010

    28/30

    Getting Started with SharePoint 2010

    Page 26 of 28

    Tasks Detailed Steps

    d. Press [CTRL] + [F5] to run the console application.e. The console application runs and displays the SharePoint site title.

    Figure 24 - SharePoint Site Name in Console Application

    f. When the site title is displayed, press [ENTER] to close the application.4. Creating Lists and

    Web Parts from

    Console application

    Note: In this task you will:

    Add existing source files containing utility classes that program against theSharePoint 2010 object model.

    Modify the Main method in the console application to programmatically create aTask, Announcement and Web Part.

    a. Return to Visual Studio.b. In the Solution Explorer window, right-click the project Lab01_OM, and then

    click Add Existing Item.

  • 8/3/2019 Gettingstarted With Share Point 2010

    29/30

    Getting Started with SharePoint 2010

    Page 27 of 28

    Tasks Detailed Steps

    Figure 25 -

    Project Right-Click Options

    c. Browse to the following location:C:\Student\Labs\01_Roadmap\StarterFiles.

    d. Click Lab01_Utilties.cs and then click Add.The Lab01_Utilties.cs source file contains three utility classes named

    TasksListFactory, AnnouncementsListFactory and WebPartPageDesigner. The

    first two classes contain code to create new l ist instances and to populate them

    with sample data. The third class named WebPartPageDesigner programs

    against a class named SPLimitedWebPartManager which is provided by the

    SharePoint 2010 object model to delete and add Web Part instance from a target

    Web Part Page.

    e. Paste the following code to replace the code in Program.cs :

    using System;

    using Microsoft.SharePoint;

    using Microsoft.SharePoint.Administration;

    namespace Lab01_OM

    {

  • 8/3/2019 Gettingstarted With Share Point 2010

    30/30

    Getting Started with SharePoint 2010Tasks Detailed Steps

    class Program {

    static void Main()

    {

    string targetSiteUrl = "http://intranet.contoso.com/sites/Lab01A";

    using (SPSite siteCollection = new SPSite(targetSiteUrl)) {

    SPWeb site = siteCollection.RootWeb;

    string TasksListTitle = "Tasks";

    string TasksListDescription = "Contoso Tasks";

    TasksListFactory.Create(site, TasksListTitle, TasksListDescription);

    string AnnouncementsListTitle = "Announcements";

    string AnnouncementsListDescription = "Contoso Announcements";

    AnnouncementsListFactory.Create(site,

    AnnouncementsListTitle,

    AnnouncementsListDescription);

    WebPartPageDesigner.ClearAll(site, "home.aspx");

    WebPartPageDesigner.AddXsltListViewWebPart(site, "home.aspx",

    "Tasks", "Left");

    WebPartPageDesigner.AddXsltListViewWebPart(site, "home.aspx",

    "Announcements", "Left");

    }

    }

    }

    }

    f. Press [F5] to run the console application.The Console application adds two new lists to the target site and two new web

    parts to the home page to display the contents of these two lists.

    g. Return to Internet Explorer and refresh the pagehttp://intranet.contoso.com/sites/Lab01A

    Review the modifications made by the console application.