309
13
Building and Deploying Web Parts
13.1 Introduction
Throughout this book we have touched on the concept of Web Parts and
Web Part pages; by now you should understand that Web Parts remain a cor-
nerstone of the SharePoint architecture, in that they are responsible for pre-
senting much of the functionality to the user. For example, the
announcements that appear on the home page of a Team site are presented to
the user though a Web Part. This chapter examines the concept of Web Parts
and Web Part pages, and where they fit into the overall SharePoint architec-
ture. SharePoint Server 2007 and Windows SharePoint Services come
equipped with a host of Web Parts that you can tailor to suit your business
needs. In this chapter we highlight two such Web Parts, the data view Web
Part and the content query Web Part, and show how they can be leveraged in
your SharePoint deployment. Finally, we show you how to increase the func-
tionality of your site by building your own custom Web Parts.
13.2 What is a Web Part?
The Web Part has come a long way since the Digital Dashboard days. The
Digital Dashboard technology was used by SharePoint Portal Server 2001,
and was superseded by the Web Part page in SharePoint Portal Server 2003
and Windows SharePoint Services 2.0. The Web Part page still exists today
and is basically an ASP.NET page that presents the user with information
derived from a variety of sources. The information is served through the use
of Web Parts. A Web Part is basically a Web control that inherits from the
System.Web.UI.WebControls.WebParts namespace and renders content to
the user. A Web Part can be placed in the desired region of a Web page. Web
Parts became very popular among the developer community because they
were easy to develop and, if coded correctly, provided much in the way of
flexibility and portability. Their successful adoption rate ultimately led to the
inclusion of the Web Part framework architecture in ASP.NET 2.0, which
310 13.2 What is a Web Part?
means that you no longer require SharePoint to leverage Web Parts in your
Web applications. As discussed numerous times throughout this book,
SharePoint Server 2007 and Windows SharePoint Services 3.0 are built upon
ASP.NET 2.0, and consequently inherit and extend many of the ASP.NET
capabilities. The ASP.NET 2.0 Web Part framework architecture is an exam-
ple of one area that SharePoint has inherited and extended by replacing com-
ponents of the Web Part framework with SharePoint-specific components.
Figure 13.1 shows the composition of an ASP.NET 2.0 page that uses Web
Parts and a WSS 3.0 Web Part Page. Any ASP.NET 2.0 page that wants to
leverage the use of Web Parts must contain one, and only one,
WebPartManager control, and one or more WebPartZone controls. The
ASP.NET 2.0
WebPartManager control is responsible for keeping track of
the Web Parts that have been added to the page and the zone in which they
were added, and also manages the customization and personalization data for
the Web Parts. A
WebPartZone control’s sole function is to provide a home
for Web Parts. Pages in SharePoint are referred to as Web Part Pages and
house an
SPWebPartManager control and one or more SharePoint specific
WebPartZone controls. The SPWebPartManager inherits from the ASP.NET
WebPartManager, and the SharePoint specific WebPartZone inherits from
the ASP.NET
WebPartZone. Both controls are used to ensure that the data
associated with each Web Part is managed and maintained in the appropriate
SharePoint content database.
A Web Part page consists of one or more Web Part zones, which in turn
contain one or more Web Parts. Web Parts that live in a zone are referred to as
dynamic Web Parts. Dynamic Web Parts and their associated properties, such
as the title of the Web Part, are stored in the SharePoint database and can be
customized and personalized by users with the appropriate permissions.
Figure 13.1
ASP.NET 2.0
Web parts.

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.