11.1. Adding Web Parts to Web Part Zones

What happens when a Web Part is dropped into a Web Part zone on a page within a SharePoint site? SharePoint adds some XML to the Web Part zone that contains information about the assembly containing the Web Part and the Web Part class itself. This XML also contains the values of the public properties on the Web Part class. This XML, shown in Listing 11-1, is then stored as personalization information for a specific user (if the personalization scope is set to User) or for all users who access the page (if the personalization scope is set to Shared) depending on the mode of the page. The next time a page is requested, SharePoint loads the personalization information for the Web Part, which tells it which class to load from which assembly and the values of the public properties to set on that class. The Web Part is then loaded within the ASP.NET 2.0 page life cycle, which generates the rendered HTML output. Figure 11-1 demonstrates what the XML in Listing 11-1 would produce. Knowing how this process works can prove to be a powerful tool for developers, as demonstrated later in this chapter.

Example 11-1. XML in a Web Part zone for the WSS 3.0 Image Web Part
<WebPart xmlns="http://schemas.microsoft.com/WebPart/v2" xmlns:iwp="http://schemas.microsoft.com/WebPart/v2/Image"> <Assembly>Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly> <TypeName>Microsoft.SharePoint.WebPartPages.ImageWebPart</TypeName> ...

Get Professional SharePoint® 2007 Web Content Management Development: Building Publishing Sites with Office SharePoint Server 2007 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.