DOCX

Hands-On Lab:Visual Studio 2010 SharePoint Tools

By Mario Carter,2014-09-23 10:14
9 views 0
Hands-On Lab:Visual Studio 2010 SharePoint Tools

Hands-On Lab

    Visual Studio 2010 SharePoint Tools

Lab version: 1.1.0

    Last updated: 9/23/2011

    Page 1

CONTENTS

    OVERVIEW ............................................................................................................................................. 3

    EXERCISE 1: CREATING A SHAREPOINT 2010 PROJECT .................................................................. 6

    Task 1 Navigating the new Site Collection ..................................................................................... 6

    Task 2 Creating a New SharePoint Project ..................................................................................... 7

    Task 3 Adding a new Feature....................................................................................................... 11

    Task 4 Adding Images to Your Project .......................................................................................... 14 EXERCISE 2: FEATURE EVENT RECEIVER ....................................................................................... 18

    Task 1 Adding a Feature Event Receiver ...................................................................................... 19

    Task 2 Adding Functionality to the Event Receiver ....................................................................... 20 EXERCISE 3: DEPLOYING AND DEBUGGING SHAREPOINT PROJECTS ........................................ 23

    Task 1 Configuring and Deploying a SharePoint Project ............................................................... 24

    Task 2 Debugging SharePoint Feature Using Visual Studio 2010 .................................................. 30 EXERCISE 4: CREATING, DEPLOYING AND TESTING WEB PARTS ................................................ 33

    Task 1 Adding a new Web Part .................................................................................................... 33

    Exercise 4: Verification ................................................................................................................... 39

    EXERCISE 5: CREATING A VISUAL WEB PART WITH AJAX BEHAVIOR ......................................... 42

    Task 1 Adding a Visual Web Part ................................................................................................. 42

    Task 2 Adding Markup to the Web Part ....................................................................................... 46

    Task 3 Implementing the Web Part ............................................................................................. 50

    Exercise 5: Verification ................................................................................................................... 53

    SUMMARY ............................................................................................................................................ 56

    Page 2

Overview

    In this lab, you will start using the Visual Studio 2010 SharePoint Developers Tools. This will give you a chance to become familiar with the standard project structure used by SharePoint Developers Tools. You will go through the steps of creating and testing a project that contains a Feature, a Feature Receiver and a Web Part. Along the way you will learn to configure the SharePoint project’s deployment

    options as well debug a SharePoint project using Visual Studio 2010 by single-stepping through the code in your solution.

    Objectives

    In this Hands-On Lab, you will learn how to:

    ; Create a brand new SharePoint project using the templates included in the SharePoint

    Developers Tools.

    ; Create and code a Feature Event Receiver in order to react to SharePoint feature activation and

    deactivation.

    ; Configure, deploy, test and debug a SharePoint project using Visual Studio 2010 SharePoint

    developers Tools.

    ; Create, modify and test SharePoint Web Parts using Visual Studio 2010.

    ; Create, modify and test SharePoint Ajax-enabled Visual Web Parts using Visual Studio 2010.

Exercises

    This Hands-On Lab is comprised by the following exercises:

    ; Exercise 1: Creating a SharePoint 2010 Project

    ; Exercise 2: Feature Event Receiver

    ; Exercise 3: Deploying and Debugging SharePoint Projects

    ; Exercise 4: Creating, Deploying and Testing Web Parts

    ; Exercise 5: Creating a Visual Web Part with AJAX Behavior

Estimated time to complete this lab: 45 minutes.

    Page 3

System Requirements

    You must have the following items to complete this lab:

    ; Microsoft Visual Studio 2010

    ; Internet Information Server 7.0

    ; Microsoft SharePoint Server 2010

    ; Microsoft SharePoint Server 2010 Developer Tools

    Note: You can follow the Set up the Development Environment for SharePoint Server article in

    order to get instruction to install SharePoint Server appropiatelly.

Setup

    All the requisites for this lab are verified using the Configuration Wizard. To make sure that everything is

    correctly configured, follow these steps.

    1. Run the Configuration Wizard for the Training Kit if you have not done it previously. To do

    this, browse to Source\Setup folder of this lab, and double-click the Dependencies.dep file.

    Install any pre-requisites that are missing (rescanning if necessary) and complete the wizard.

    Note: The Configuration Wizard is used for checking dependencies and setting up the

    environment. If the Configuration Wizard is not installed on your machine, you must install it

    running the DependencyChecker.msi file located on

    the %VS2010TKInstallationFolder%\Assets\DependencyChecker folder (e.g. by default the

    Training Kit is installed under C:\VS2010TrainingKit).

    The Configuration Wizard will also setup a new blank site collection at the location

    http://localhost/sites/SharePointToolsLab. This is the site you will use to test and debug the

    code you are going to write with the Visual Studio 2010 SharePoint Tools. If you want to

    change the site collection location, modify the SetupSiteCollection.ps1 in the

    Setup\scripts\tasks folder of this lab.

Starting Materials

    This Hands-On Lab includes the following starting materials.

    Page 4

; Each exercise is accompanied by a starting solution you can find in the Begin folder of each

    exercise. Some code sections are missing from these solutions, which will be completed through

    each exercise. Therefore the starting solutions will not work if you run them directly. ; Inside each exercise you will also find an End folder containing the resulting solution you should

    obtain after completing the exercises. You can use this solution as a guide if you need additional

    help working through the exercises.

    ; Each exercise contains a Visual Basic and a C# version; Inside the End/Begin solution folder you

    will find two folders: VB, containing the Visual Basic version of the exercise, and C#, containing

    the C# version of it.

Next Step

    Exercise 1: Using HTML Code Snippets in Visual Studio 2010

    Page 5

    Exercise 1: Creating a SharePoint 2010 Project

    In the first exercise, you will create an empty project and focus on the aspects of the Visual Studio 2010 SharePoint Tools that are common across all projects created with this toolset. Most of your work will involve changing the properties of the project and properties of the project's main feature. Task 1 Navigating the new Site Collection

    In this task, you will verify that an empty SharePoint Site Collection was created using the Configuration Wizard application.

    1. Launch the Internet Explorer and navigate to the top-level site at

    http://localhost/sites/SharePointToolsLab. You should observe that the newly-created site is a

    Blank site. This is the site you will use to test and debug the project you will develop throughout

    this entire lab exercise.

    Figure 1

    Page 6

    SharePoint Blank Site Collection

    Note: If you haven’t already done so, run the Configuration Wizard for the Lab to create the

    new site collection that will be used to test and debug the code you will be writing in this lab.

    Remember to change the site URL if you modified it in the setup scripts.

Task 2 Creating a New SharePoint Project

    In this task, you will use the templates included in Visual Studio 2010 to create an Empty SharePoint

    project.

    1. Open Microsoft Visual Studio 2010 from Start | All Programs | Microsoft Visual Studio 2010 |

    Microsoft Visual Studio 2010.

    2. On the File menu, point to New, and click Project.

    3. In the New Project dialog box make sure that .NET Framework 3.5 is selected and select either

    Visual C# or Visual Basic, then select SharePoint 2010 in the Installed Templates list and the

    Empty SharePoint Project type. You may set the location to the Source\Ex1-

    CreatingSharePointProject\begin (choosing the folder that matches the language of your

    preference) which is the provided folder for this lab.

    Note: .NET Framework 4.0 is currently not supported by SharePoint 2010 and the SharePoint

    Project template will set the target framework attribute to .NET Framework 3.5.

4. Change the Name to ContosoWebParts and click OK.

    Page 7

Figure 2

New Empty SharePoint Project (C#)

Page 8

Figure 3

    New Empty SharePoint Project (VB)

    5. When the SharePoint Customization Wizard prompts you for a local debugging site, enter http://localhost/sites/SharePointToolsLab and change the trust level to Deploy as a farm solution and then click Finish.

    Page 9

Figure 4

    SharePoint Customization Wizard

    Note: Sanboxed solution has certain restrictions, such as being unable to access filesystem, even during deployment. The deployment of ASCX files is not allowed in a sandbox solution, since your project will contain a user control, you need to create a farm solution. For more information on Sandboxed solutions please visit: http://msdn.microsoft.com/en-

    us/magazine/ee335711.aspx

    6. Once the new project has been created, you should be able to observe it has four nodes: Properties, References, Features and Package. While the first two nodes are standard on all

    Visual Studio projects, the Features node and the Package node are unique to projects create with the Visual Studio 2010 SharePoint Tools.

    Page 10

Report this document

For any questions or suggestions please email
cust-service@docsford.com