13.4 Creating Custom Web Parts 341
Chapter 13
by navigating to the shared services administration page, which is accessible
from the central administration page. From the shared services administra-
tion page, click the Search Settings link. From the search settings page, click
the Metadata property mappings link and add a new managed property.
13.4 Creating Custom Web Parts
As we can see, SharePoint comes equipped with many useful Web Parts out
of the box, and many more are available from the Microsoft online gallery
and through third-party vendors. However, there will be times when you
need a Web Part that is not available from these sources and is very specific to
your business needs. Fortunately, SharePoint is highly extensible and allows
Figure 13.33
content query
Web Part.
342 13.4 Creating Custom Web Parts
you to develop your own custom Web Parts using industry-standard develop-
ment tools such as Visual Studio 2005.
The following section steps you through the basics of how to create two
simple Web Parts. The main purpose of this section is to walk you through
creating your first Web Part as quickly as possible and to familiarize you with
the basic steps involved in deploying a Web Part. Later in the chapter, we will
discuss more advanced Web Part development techniques, such as creating
custom tool parts and creating connectable Web Parts.
Since Windows SharePoint Services 3.0 and SharePoint Server 2007 are
built upon ASP.NET 2.0, as developers you now have two methods of creating
SharePoint Web Parts. The first method involves creating Web Parts that inherit
from the ASP.NET 2.0
base class; this is the Microsoft-recommended method for Web Part develop-
ment. The second method involves creating a Web Part that inherits from the
Windows SharePoint Services 3.0
WebPart class. The WSS 3.0 WebPart class
was carried forward from Windows SharePoint Services 2.0, and is mostly avail-
able for backward-compatibility purposes. While inheriting from the ASP.NET
2.0 is generally the best technique to adopt when developing Web Parts, there
may be times that you need to use the WSS 3.0
WebPart class. For example, if
you would like your Web Part to be able to connect with a Web Part on another
page, you would inherit from the WSS 3.0
WebPart class because it supports
cross-page connections. Scenarios that would dictate the use of the WSS 3.0
WebPart class rather than the preferred ASP.NET 2.0 WebPart class include:
n Cross-page connections
n Connections between Web Parts outside of a Web Part zone.
n Client-side connections that leverage the Web Part page services com-
n Caching data to the content database
This chapter focuses on developing Web Parts using the ASP.NET 2.0
WebPart class. More information on developing Web Parts that use the WSS
WebPart class can be found in the Microsoft WSS 3.0 SDK.
13.4.1 Getting Started
Since Web Parts are basically ASP.NET Web controls, you can use Visual
Studio 2005 to perform all Web Part development. To make development
easier, Microsoft has provided a Web Part template that is available as part of
the Visual Studio 2005 Extensions package, which can be downloaded from
MSDN. This template provides skeleton code and the appropriate files and

Get Microsoft SharePoint 2007 Technologies now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.