Personalizing Using Web Parts->Introducing Web Part Controls

↘锁芯ラ 提交于 2020-03-01 22:45:40

Introducing Web Part Controls

The Web Part Control Set includes the following controls:
  • Web Parts are ASP.NET server controls that can be used and personalized with the Web Part Control Set. Any ASP.NET server control or user control can behave as a web part. 
  • Web Part Zones provide a way to organize parts into regions on the page. Zones are container controls that provide layout for parts, and add common, consistent UI elements such as a Verb Menu and border to each part.
  • The WebPartManager control manages the pages personalization state, and co-ordinates communication between parts and zones. Every page that uses the Web Part Control Set must have a WebPartManager control on it.
The following code shows a web part zone with a single part. The parts in a zone are contained in the zone's ZoneTemplate. 

<asp:WebPartZone ID="WebPartZone1" Runat="server">
<ZoneTemplate>
<asp:Calendar Runat="server" ID="Calendar1"/>
</ZoneTemplate>
</asp:WebPartZone>
This example shows a simple page that uses web parts. It includes a WebPartManager control, a WebPartPageMenu control, and two web part zones. One of the zones contains an ASP.NET Calendar control.
  1. Log in to the page.
  2. Select "Design" from the menu's DropDownList.
  3. Move Web Parts to different WebPartZones.
  4. Close the browser, and run the sample again. You will see your personalized changes have been applied.
VB Web Parts and Zones


Web parts pages can also contain web parts that are not visible by default. The user can add these parts to the page through a web part catalog. A web part catalog allows you to define optional content not visible by default on the page.

To provide a catalog on the page, you need to add a special zone control, called the CatalogZone, to your page. In this zone, you can add catalog parts that provide different kinds of controls. This example shows a page with a CatalogZone containing a PageCatalogPart, which provides a catalog of all closed web parts defined on the page.
  1. Log in to the page.
  2. Click the dropdown arrow on the control's verbs Menu then click the Close verb on the calendar to close the Web Part.
  3. Select "Catalog" from the menu's DropDownList.
  4. Check the checkbox next to the part named "Untitled", and click the Add button. The calendar will be added back to the first zone.
VB Web Part Catalogs


In addition to allowing users to personalize the layout and visibility of web parts on a page, you can also let users edit properties of each web part. Every part has a set of default properties that can be personalized. Each control can also provide additional properties to be personalized.

To allow editing of control properties, you need to add a special zone control, called the EditorZone, to the page. To this zone, you can add one or more editor parts. The following editor parts are provided:
  • The AppearanceEditorPart control allows users to edit the visual appearance of a web part.
  • The BehaviorEditorPart control allows users to edit behavior properties of a web part.
  • The LayoutEditorPart control allows users to edit the layout of a web part.
  • The PropertyGridEditorPart control displays a property grid that allows users to edit custom personalizable properties for a web part.
You can also create your own custom editor parts by inheriting from the EditorPart base class.

This example shows a page with an EditorZone containing an AppearanceEditorPart.
  1. Log in to the page.
  2. Select "Edit" from the menu's DropDownList.The editor will now be visible.
  3. Click the Edit Verb on the calendar's Verbs Menu to edit the Web Part.
  4. Edit the title in the editor, and click OK. The title of the calendar will now be updated.
VB Web Part Editors

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!