Compartilhar via


Web Parts Overview

A Web Part is a modular unit of information that has a single purpose and that forms the basic building block of a Web Part Page. Each instance of a specific Web Part may be similar or different in appearance and behavior, but it is based on the same Web Part assembly file installed on the site server. There can also be code for more than one Web Part in a Web Part assembly file.

Microsoft® Windows® SharePoint™ Services comes with several Web Parts that users can use right away, and many more are available in the online Web Part gallery. In addition, you can create your own Web Parts or install Web Parts from Microsoft or other software vendors.

Writing a custom Web Part requires a development tool such as Microsoft Visual Studio® .NET. All custom Web Parts are derived from the WebPart base class. This class provides basic properties that are common to all Web Parts, such as Title, Description, and so on. You can add any necessary custom properties to your derived class and, at run time, the two sets of properties are presented and run as a single set of properties.

Following are some ways in which you can use custom Web Parts:

  • Creating custom properties and using the Web Part infrastructure to display them in the tool pane.
  • Creating custom Tool Parts in the tool pane.
  • Creating a base class for other Web Parts to extend. For example, to create a collection of Web Parts with similar features and functionality, create a custom base class from which multiple Web Parts can inherit. This reduces the overall cost of developing and testing subsequent Web Parts.
  • Improving performance and scalability. A compiled custom Web Part runs faster than a script.
  • Securing and controlling access to content within the Web Part. The built-in Web Parts allow any users with appropriate permissions to change content and alter Web Part functionality. With a custom Web Part, you can determine the content or properties to display to users, regardless of their permissions.
  • Making your Web Part connectable by implementing one or more of the defined Web Part Connection interfaces. This allows the custom Web Part to provide or access data from other connectable Web Parts.
  • Interacting with the object models that are exposed in Microsoft SharePoint Products and Technologies. For example, you can create a custom Web Part to save documents to a Windows SharePoint Services document library.
  • Controlling the cache for the Web Part by using built-in cache tools. For example, you can use these tools to specify when to read, write, or invalidate the Web Part cache.
  • Benefiting from a rich development environment with debugging features that are provided by tools such as Visual Studio .NET.
  • Implementing proprietary code without disclosing the source code.
  • Controlling the implementation of the Web Part. For example, you can write a custom server-side Web Part that connects to a back-end database, or you can create a Web Part that is compatible with a broader range of Web browsers.

For more information about the Web Part infrastructure, see Web Part Infrastructure and Web Part Infrastructure Concepts. For an example of how to create a simple Web Part, see Creating a Basic Web Part.