Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

Unit 08: Exploring the Windows

SharePoint Services Object Model

Contents
Overview 1
Exploring the Windows SharePoint Services
Object Model 2
Programming with Windows SharePoint
Services Object Model in Visual Studio .NET 3
Lab A: Programming with Windows
SharePoint Services Object Model in Visual
Studio .NET 4
Lab Discussion 8
Information in this document, including URL and other Internet Web site references, is subject to
change without notice. 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. 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.

 2003 Microsoft Corporation. All rights reserved.

Microsoft, MS-DOS, Windows, Windows NT, <plus other relevant MS trademarks, listed
alphabetically. The publications specialist replaces this example list with the list of trademarks
provided by the copy editor. Microsoft, MS-DOS, Windows, and Windows NT are listed first,
followed by all other Microsoft trademarks listed in alphabetical order.> are either registered
trademarks or trademarks of Microsoft Corporation in the United States and/or other countries.

<The publications specialist inserts mention of specific, contractually obligated to, third-party
trademarks, provided by the copy editor>

The names of actual companies and products mentioned herein may be the trademarks of their
respective owners.
Unit 08: Exploring the Windows SharePoint Services Object Model 1

Overview

The Windows SharePoint Services object model is integrated with Microsoft ASP.NET. This enables
developers to program the Windows SharePoint Services object model in Microsoft Visual Studio .NET
environment to customize Web Parts for use in a Windows SharePoint Services deployment.

Objectives
After completing this unit, you will be able to:
„ Understand the capabilities of Windows SharePoint Services Object Model
„ Use Visual Studio .NET to program Windows SharePoint
2 Unit 08: Exploring the Windows SharePoint Services Object Model

Exploring the Windows SharePoint Services Object


Model

You can use the Windows SharePoint Services object model in code running on the server to access and
work with lists or Web site data and templates, to customize Web Part views of list data, or to manage a
top-level site or a subsite. The object model is fully integrated with Microsoft ASP.NET so that you can
work within the Microsoft Visual Studio .NET integrated development environment (IDE) to develop
custom Web applications or to customize Web Parts for use in a Windows SharePoint Services
deployment.
The Windows SharePoint Services object model provides extensive access to list data, list views,
administration, and almost all other aspects of a SharePoint site.
Unit 08: Exploring the Windows SharePoint Services Object Model 3

Programming with Windows SharePoint Services Object


Model in Visual Studio .NET

The Microsoft Visual Studio .NET integrated development environment (IDE) offers a solid
platform for customizing a site based on Microsoft Windows SharePoint Services.
You need to take certain steps in order to use the integrated development environment when
customizing a SharePoint Web site.
To use this environment, you need to:
„ Use a specific path when creating a Web application
„ Set a reference to Microsoft.SharePoint.dll
„ You may also need to add a Multipurpose Internet Mail Extensions (MIME) type in Internet
Information Services (IIS)
4 Unit 08: Exploring the Windows SharePoint Services Object Model

Lab A: Programming with Windows SharePoint Services


Object Model in Visual Studio .NET

After completing this lab, you will be able to:


„ Create a Web application
„ Set a reference to the Windows SharePoint Services assembly
„ Enumerating SharePoint Portal Server lists

Solution Files
The solution files provide you the Microsoft Visual Studio .NET project as it would appear after
successfully completing all of the exercises in this lab. The solution files may be accessed at the
following locations:
„ C# solution files:
C:\Program Files\Microsoft Learning\2014\Labfiles\Unit 08\CS\Solution

„ Visual Basic .NET solution files:


C:\Program Files\Microsoft Learning\2014\Labfiles\Unit 08\VB\Solution

Estimated time to complete this lab: 30 minutes


Unit 08: Exploring the Windows SharePoint Services Object Model 5

Exercise 1
Creating a SharePoint Web Application
In this exercise, you will create a Web application.

Tasks Supporting information

1. Create a custom Web • Visual Studio .NET is the primary tool for creating Web Applications
application within the • The Location of the Web application should be:
context of a SharePoint
installation. http://Dublin/_layouts/Web_Application_name
Creating the custom application in the _layouts directory makes the
project accessible to all sites on the server.
• The password for Dublin is: P@ssw0rd

See the Toolbox resource: Answer Key for Exercise 1


6 Unit 08: Exploring the Windows SharePoint Services Object Model

Exercise 2
Setting a Reference to the Windows SharePoint Services
Assembly
In this exercise, you will set a reference to the Windows SharePoint Services assembly.

Tasks Supporting information

1. Add a reference to the The process for setting a reference varies, depending on whether you
Windows SharePoint Services are using Visual Studio .NET on a remote computer or on the server
assembly to implement running Windows SharePoint Services.
Intellisense features in the
Object Browser and Code
Editor.. See the Toolbox resource: Answer Key for Exercise 2
Unit 08: Exploring the Windows SharePoint Services Object Model 7

Exercise 3
Enumerating a SharePoint Portal Server List
In this exercise, you will enumerate a SharePoint Portal Server list.

Tasks Supporting information

1.

2. Add three using (C#) or • There may be times when you need to batch or automate several
Imports (Visual Basic .NET) administrative tasks in SharePoint Portal Server; a good way for
directives to the performing repetitious tasks is to user Windows SharePoint
WebForm1.aspx file that Services Object Model. Anything you can do in the
reference the namespaces: administrative or browser user interface, you can also do
• Microsoft.SharePoint programmatically in the Windows SharePoint Services Object
Model.
• Microsoft.SharePoint.Web
See the Toolbox resources:
Controls,
• Code Sample, Using Directives
• Microsoft.SharePoint.Utili
ties. • Answer Key for Exercise 3
3. In the WebForm1.aspx file,
add a label, text box, and
button.
4. Add code to the button If you are creating a Web application that modifies data in the content
handler to: database, you need to add a FormDigest control and a page directive to the
.aspx file containing the form.
• Return a user object for
the user name specified in
the text box.
See the Toolbox resources:
• Provide a list of site
• Programmability in Microsoft Windows SharePoint
groups to which that user
Services
belongs
• Code Sample, Return a User Object for a Given User
Name
• Answer Key for Exercise 3
5. Verify that when you type the • Use the password: P@ssw0rd
logon name of a user on the
site, the label displays the
Web sites and site groups to
which the specified user
belongs.
8 Unit 08: Exploring the Windows SharePoint Services Object Model

Lab Discussion

Discussion of the lab exercises:


„ Were there issues that hindered you from completing of the exercise tasks?
„ Do you have any general comments about the exercises?

You might also like