Microsoft Share Point 2010 Developer Tools

  • View
    269

  • Download
    1

Embed Size (px)

Transcript

Hands-On LabVisual Studio 2010 SharePoint ToolsLab version: 1.0.0 Last updated: 5/4/20104/14/20103/4/20102/2/2010

Page 1

CONTENTSField Code Changed

OVERVIEW ................................ ................................ ................................ ................................ ............. 3Field Code Changed

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................................ ................................ .................. 141413EXERCISE 2: FEATURE EVENT RECEIVER................................ ................................ ........................ 18

Field Code Changed Field Code Changed Field Code Changed Field Code Changed Field Code Changed

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

Field Code Changed Field Code Changed Field Code Changed

Task 1 Configuring and Deploying a SharePoint Project................................. .............................. 23 Task 2 Debugging SharePoint Feature Using Visual Studio 2010................................ ........... 303029EXERCISE 4: CREATING, DEPLOYING AND TESTING WEB PARTS ................................ ........ 333331

Field Code Changed Field Code Changed Field Code Changed

Task 1 Adding a new Web Part................................ ................................ ............................ 333331 Exercise 4: Verification................................ ................................ ................................ ........... 393937EXERCISE 5: CREATING A VISUAL WEB PART WITH AJAX BEHAVIOR ................................ . 424240

Field Code Changed Field Code Changed Field Code Changed

Task 1 Adding a Visual Web Part ................................ ................................ .......................... 424240 Task 2 Adding Markup to the Web Part................................ ................................ ............... 464644 Task 3 Implementing the Web Part ................................ ................................ ...................... 505048 Exercise 5: Verification................................ ................................ ................................ ........... 535351SUMMARY ................................ ................................ ................................ ................................ .... 565654

Field Code Changed Field Code Changed Field Code Changed Field Code Changed Field Code Changed

Page 2

OverviewOverviewIn this lab you willstart using the Visual Studio 2010 SharePointDevelopers 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, aFeature Receiver and a Web Part. Along the way you will learn to configure the SharePoint project sdeployment options as well debug a SharePointproject using Visual Studio 2010 by single-stepping through the code in your solution.

ObjectivesIn this Hands-On Lab, you will learn how to: y 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.

y

y

y y

ExercisesThis Hands-On Lab is comprised by the following exercises: y y y y y Creating a SharePoint 2010 ProjectCreating a SharePoint 2010 Project Creating a Feature Event ReceiverCreating a Feature Event Receiver Deploying and Debugging SharePoint Projects Deploying and Debugging SharePoint Projects Creating, Deploying and Testing Web PartsCreating, Deploying and Testing Web Parts Creating a Visual Web Part with AJAX BehaviorCreating a Visual Web Part with AJAX Behavior

Estimated time to complete this lab: 45 minutes.

Page 3

System RequirementsYou must have the following items to complete this lab: y y y y Microsoft Visual Studio 2010 Beta 2 Internet Information Server 7.0 Microsoft SharePoint Server 2010 Beta Microsoft SharePoint Server 2010 Beta Developer Tools Note: You can follow theSet up the Development Environment for SharePoint Serverarticle in order to get instruction to install SharePoint Server appropiatelly.

SetupAll the requisites for this lab are verified using theConfiguration Wizard. To make sure that everything is correctly configured, follow these steps. Note: To perform the setup steps you need to run the scripts in a command window with administrator privileges.

1. Run the Configuration Wizard for the Training Kit if you have not done it previously. To do this, run the CheckDependencies.cmd script located under the Setup folder of this lab. Install any pre-requisites that are missing (rescanning if necessary) and complete the wizard . Note: The Configuration Wizard will setup a new blank site collection at the locati n o 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.ps1in the Setup\scripts\tasks folder of this lab.

Comment [ZN1]: Put your computer name here NOT localhost Comment [ZN2]: Your URL will most likely not have this Comment [ZN3]: Dont bother the script wont work anyway. Its easier to just create your own blank site on your own.

Starting MaterialsThis Hands-On Lab includes the following starting materials. y 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.

Page 4

y

Inside each exercise you will also find anEnd 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.

y

Next StepExercise 1: Using HTML Code Snippets in Visual Studio 2010 Exercise 1: Using HTML Code Snippets in Visual Studio 2010

Page 5

Exerc se 1: Creat ng a SharePo nt 2010 ProjectExerc se 1: Creat ng a SharePo nt 2010 ProjectI t e f rst exerc se y create a e ty r ect a f c s t e as ects f t e s a St S areP t T s t at are c acr ss a r ects create t t s t set. st f y r rk v ve c a g g t e r ert es f t e r ect a r ert es f t e r ect's a feat re .

I t s task y zar a cat

ver fy t at a e

ty S areP

t S te

ect

as creae t

s gt e

f g rat

.

av gate t t e t - eve s te at 1. La c t e I ter et Ex rer a htt //localhost/sites/ Share o i tToolsLa Y s serve t at t e e y -create s te s a a k s te. T s s t e s te y se t est a t e g t e r ect y eve t r g t t s e t re a exerc se.

Page 6

CB D C B D R B E P P F

! &

F EE PI CB EI H D

! '

D

B C EE PI CB SB R D CG F FH P A @ 9 GB F EC BD C B 432 6 3 324 1 4 6 0 50

"

## &

%$

P G E D P PD

0

0 1 1 0)

#%% ' ( # # " !

Task 1

avigati g the ew Site Collectio

P H PD H EQ 87 P

2010

Figure 112 SharePoint Blank Site Collection Note:If you haven t already done so, run the Configuration Wizard for the Labto 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 Ne

In this task, you will use the templates included in Visual Studio 2010 Beta 2 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 Ne , and click Project. 3. In the Ne Project dialog box make sure that .NET Frame ork 3.5is selectedandselect either Visual C# or Visual Basic, then selectSharePoint 2010 in the installed Templates listand theEmpty SharePoint Project type. You may set the location to the Source\Ex01CreatingSharePointProject\begin (choosing the folder that matches the language of your preference) which is the provided folderfor this lab. Note: .Net Framework 4.0 is currently not supported by SharePoint 2010

4. Change the Name to ContosoWebParts and click OK.

Page 7

V