Overview of the Web Part Framework


A Web Part is an ASP.NET control that is contained within a Web Part Zone. Any ASP.NET control can be used as a Web Part, including any standard ASP.NET control such as the GridView, Image, or LinkButton control. You can also create a Web Part by creating a new User control or a new custom Web control.

Note

ASP.NET 2.0 Web Parts will be used in the next version of Windows Sharepoint Services (WSS) and Microsoft Office Sharepoint Portal Server (SPS). The good news is that if you develop Web Parts for the ASP.NET 2.0 Framework, then the Web Parts will work with the new versions of these products when they are released. The bad news is that ASP.NET 2.0 Web Parts are not compatible with the current implementation of Web Parts used in these two products.


Because you can create a new Web Part by creating a new control, a Web Part can do anything you want. You can create an Email Client Web Part, a Random Quotation of the Day Web Part, a Shopping Cart Web Part, or a Task List Web Part. Anything you can do in the ASP.NET Framework, you can do with Web Parts.

When you add an ASP.NET control to a Web Part Zone, the control automatically gets several special capabilities. For example, you can drag and drop a Web Part from one Web Part Zone to another. You can minimize and maximize a Web Part. You can modify the properties of a Web Part and the modifications are automatically saved.

Note

The next chapter is devoted exclusively to the topic of building Web Parts.


Web Parts are just one type of control included in the Web Part Framework. You can use several different types of parts when building a Web Part page. You can also add several different types of zones to a Web Part page.

Web Part Zones

When you build a page that contains Web Parts, you divide the page into different zones. Each zone is responsible for managing and rendering a particular type of part. There are four standard types of zones included in the Web Part Framework:

  • Web Part Zones This type of zone is used to render Web Parts. You can add Web Parts to a Web Part Zone and drag and drop Web Parts between different Web Part Zones.

  • Editor Zones This type of zone is used to render Editor Parts. Use Editor Parts to enable a user to edit Web Part properties.

  • Catalog Zones This type of zone is used to render Catalog Parts. Use Catalog Parts to display lists of Web Parts that a user can add to a page.

  • Connections Zones This type of zone is used to display an interface that enables users to connect Web Parts dynamically.

Note

You can extend the Web Part Framework with custom zones. We'll explore this option in Chapter 30, "Extending the Web Part Framework."


Every page that contains Web Parts contains at least one Web Part Zone. A Web Part Zone is used to lay out the Web Parts on a page.

The other types of zones are known collectively as tool zones. Adding a tool zone to a page is optional. If you don't want a user to add new Web Parts to a page, then don't include a Catalog Zone in the page. If you don't want a user to be able to edit or connect Web Parts, then don't add Editor or Connections Zones to a page.

Web Part Display Modes

By default, when you first open a page that contains Web Parts, the only type of zone that is rendered is Web Part Zones. To display the other types of zones, you must change the page's Display Mode.

At any time, a page can be in one of the following Display Modes:

  • Browse The default mode. In this mode, you cannot rearrange or edit Web Parts.

  • Design In this mode, you can drag and drop Web Parts from one Web Part Zone to another.

  • Edit In this mode, you can edit a Web Part's properties by using one or more Editor Parts.

  • Catalog In this mode, you can add new Web Parts to a page from one or more Catalog Parts.

  • Connect In this mode, you can create dynamic connections between Web Parts.

A page that contains Web Parts can be in only one Display Mode at a time. If you switch to Edit Display Mode, then the contents of any Editor Zones are rendered and you can edit Web Parts. If you switch to Catalog Display Mode, then the contents of any Catalog Zones are rendered and you can add new Web Parts. However, you cannot set a page to both Edit and Catalog Display Mode at the same time.

Note

You can extend the Web Part Framework with custom Display Modes. We'll explore this option in Chapter 30.


Web Part Personalization

When a user makes changes to a Web Part's properties, the Web Part Framework automatically saves these changes. For example, a user can add one or more Web Parts to a page and arrange the Web Parts with a particular layout. If the user returns to the page in the future, the Web Parts will remember the layout. This feature of the Web Part Framework is called personalization.

The Web Part Framework supports two types of personalization: User and Shared. By default, all changes made to a Web Parts page have User scope. Changes are scoped to a particular user, which enables each user to personalize the same page in different ways.

The Web Part Framework also supports Shared scope personalization. An administrator of a Web Part application can make changes that have an effect on everyone who uses the application. For example, an administrator might want to add a standard set of Web Parts to a page and prevent individual users from removing them.

Note

This chapter sticks to User scope personalization. In Chapter 29, "Personalizing Web Parts," the topic of User and Shared scope personalization is examined in detail.


For personalization to work, the Web Part Framework must have a method of identifying users. The default personalization provider included with the Web Part Framework requires that users be authenticated. If you use the default provider, then an unauthenticated user can browse, but not customize, a Web Part application. (In Chapter 29, you learn how to create a custom personalization provider.)

Warning

You must enable authentication for your application for many of the sample pages in this chapter to work. By default, Windows Authentication is enabled. For more information about enabling authentication, see Chapter 20, "Using the Login Controls."





ASP. NET 2.0 Unleashed
ASP.NET 2.0 Unleashed
ISBN: 0672328232
EAN: 2147483647
Year: 2006
Pages: 276

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net