Creating Client-Side Web Parts

You can do a lot with SharePoint Designer, and you might be tempted to use it to add formatted text, tables, and other types of content to SharePoint pages. Don't do it. One of the biggest benefits of SharePoint is the ability to edit pages through the web browser, and editing pages in a designer ignores that benefit, harms performance, and can break pages. Instead, use one of the web parts listed in Table 6-4 to include custom content.

Table 6-4. Web parts used for including custom content

Web part

Use to

Content Editor

Add formatted text, HTML controls, JavaScript, Flash animations, etc.

Page Viewer

Display a page, file, or folder from another location in an IFrame.

XML Web Part

Render XML output using an XSL transformation.

Once you create your web part, you can export it, then deploy it for reuse as described in the preceding section. I call these client-side web parts because any code they include runs on the client—you can't include ASP.NET code or access the SharePoint object model, but you can still do a lot.

Including Repeated Elements

Use the Content Editor to include an element on multiple pages. You can import HTML files using the Content Editor, so you can store your element one place and use it throughout a site collection. To see how that works:

  1. Navigate to the top-level site and create a library named "Includes." Use these settings: Display this document library on the Quick Launch? No; Document Template, None.

  2. Check the library's Permissions settings ...

Get Essential SharePoint 2007, 2nd Edition 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.