Web Part Basics

Web Parts in Microsoft® SharePoint™ Products and Technologies 2003 improves upon and replaces earlier versions of Web Parts technologies, such as the Digital Dashboard concept. You can view and interact with Web Parts that are associated with sites in Windows SharePoint Services and SharePoint Portal Server. You can also view Web Parts as part of shared Web Part Page documents in Microsoft® Office Project Web Access 2003. The shared documents are stored and managed on a computer running Windows SharePoint Services that is provisioned by Project Server 2003.

In essence, a Web Part is a .NET Web custom control assembly that uses a Web Part description file (.dwp). The .dwp file can be stored on and referenced from any computer, and contains XML metadata that describes an instance of the Web Part. The .NET Web Part assembly is a DLL that must be installed and registered on each computer running Windows SharePoint Services that uses the Web Part. The topic Installing and Using the Custom Web Parts .NET Assembly describes the process of registering the Web Part assembly that is included with the download and creating a .dwp file for it.

To create and export a simple Web Part, you can open any Windows SharePoint Services or SharePoint Portal Server page that you have permission to modify, configure any Web Part on that page, and then export the .dwp file. Because the .dwp file is a description of a Web Part instance, you can edit the file in any text editor on another computer and then import the .dwp file again to show a modified Web Part. The Web Part code (the Web Part class, or object in the DLL) does not travel with the Web Part description.

To create a basic Web Part:

The following example shows a server running Windows SharePoint Services that has been provisioned with a Project Server workspace on port 5555. You can use any server running Windows SharePoint Services to which you have access.

  1. In your browser, enter the URL of your Project Workspace Home page, for example:

    http://WSSServerName:5555/sites/MS_ProjectServer_PublicDocuments/default.aspx
    
  2. Click Modify Shared Page, click Add Web Part, and then click Browse.

  3. In the Add Web Parts pane, click the Project Workspace Gallery. Click the Content Editor Web Part and then drag and drop it below a section in the middle of the page. If you are not using a server running Windows SharePoint Services that is provisioned with a Project Server workspace, browse the available Web Part galleries for the Content Editor Web Part.

    The following image shows an example of dragging the Content Editor Web Part.

    Dragging a Content Editor Web Part to a Web Part Page

  4. Click the link open the tool pane in the Content Editor Web Part, or click the down arrow at the top right of the Web Part, and click Modify Shared Web Part in Web Part Menu.

  5. In the Content Editor Web Part properties pane, click either Source Editor or Rich Text Editor. In the Rich Text Editor, type in one or two sentences, or in the Source Editor type in the HTML code for the two sentences. For example:

    <P>Climb mountains to see lowlands.</P><P>&nbsp; --Chinese Proverb</P>
    
  6. Click Apply. The modified Web Part appears as in the following image.

    Modified Content Editor Web Part

  7. Click the down arrow at the top right of the Web Part, and click Export in Web Part Menu. Then click Save, and in the Save As dialog box, type a file name such as WebPartBasics.dwp and select a directory in which to save your Web Part instance description.

Following is the resulting WebPartBasics.dwp file. You can modify text elements of this file, such as the Title or Description elements, and import the modified WebPartBasics.dwp file to another Web Part Page in Windows SharePoint Services or SharePoint Portal Server.

<?xml version="1.0" encoding="utf-8"?>
<WebPart xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/WebPart/v2">
  <Title>Content Editor Web Part</Title>
  <FrameType>Default</FrameType>
  <Description>Use for formatted text, tables, and images.</Description>
  <IsIncluded>true</IsIncluded>
  <ZoneID>Left</ZoneID>
  <PartOrder>3</PartOrder>
  <FrameState>Normal</FrameState>
  <Height />
  <Width />
  <AllowRemove>true</AllowRemove>
  <AllowZoneChange>true</AllowZoneChange>
  <AllowMinimize>true</AllowMinimize>
  <IsVisible>true</IsVisible>
  <DetailLink />
  <HelpLink />
  <Dir>Default</Dir>
  <PartImageSmall />
  <MissingAssembly />
  <PartImageLarge>/_layouts/images/mscontl.gif</PartImageLarge>
  <IsIncludedFilter />
  <Assembly>Microsoft.SharePoint, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>
  <TypeName>Microsoft.SharePoint.WebPartPages.ContentEditorWebPart</TypeName>
  <ContentLink xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor" />
  <Content xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor"><![CDATA[
     <P>Climb mountains to see lowlands.</P><P>&nbsp; --Chinese Proverb</P>
  ]]></Content>
  <PartStorage xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor" />
</WebPart>

The six Project Server Web Parts that are installed when you integrate Project Server 2003 with Windows SharePoint Services are based on the same Content Editor Web Part. For more information, see Using the Default Project Server Web Parts.

Note  The Assembly element must be all on one line, and it must be identical to the Assembly line in the Content Editor Web Part on your Windows SharePoint Services computer.

For more information on Web Parts and Web Part Pages, see the Microsoft SharePoint Products and Technologies 2003 Software Development Kit (SDK).