Adding Editor Zones

You can modify Web Part properties at runtime by using a combination//结合 of EditorZone and EditorPart controls. Editable items include the title, size and location.

In keeping with//与...相一致 the Web Part design methodology//方法学,方法论, "zone controls" are containers //容器for "part controls". In this section you will add an EditorZone control that contains an AppearanceEditorPart control. This will give your site users the ability to personalize//个性化 the appearance of the page's Web Parts.

1. From the ToolBox drag an EditorZone control onto the WebParts.aspx design surface, placing it in the right column//列 of the layout table. Set its ID property to "appearanceEditorZone".

2.  Drag an AppearanceEditorPart control into the EditorZone control, as shown below.

3. To switch //交换to the Edit display mode you must add another option to the RadioButtonList control. Open the RadioButtonList Tasks menu and click Edit Items. Add a new item called "Edit", and then click OK.

4. Double-click the RadioButtonList control, and to the existing flow control statement//流控制语句 in the SelectedIndexChanged event handler, add the following, which supports switching //转换到to the Edit display mode:

C# VB  
case 2:
            authorsWebPartManager.DisplayMode = WebPartManager.EditDisplayMode;
            break;
            

5. In the Solution Explorer select login.aspx and then press F5 to run the application. Log in//登入 as one of the application's users. Navigate to//浏览到 WebParts.aspx, and then select Edit. Click the calendar Web Part's menu and notice the new Edit option, added now that you are in Edit mode.

6. In the Web Part menu click Edit. In the Editor Zone form, for Title enter "My Calendar". For Chrome Type select Title and Border, and then click OK.

As you can see, this resulted in a new calendar title and removal //移除of the thin black border around the calendar (but not around the WebPartZone itself).

This walkthrough//初排(地下步行道) has showed you how easy it is to extend your site's personalization features to support customizing various Web Part properties. Be sure to experiment with the other new EditorPart controls in the ToolBox.

posted on 2007-04-13 10:56  改变热爱  阅读(215)  评论(0)    收藏  举报

导航