Default.aspx
1. Open Default.aspx in Design view. From the WebParts section//块,部分 of the Toolbox, drag//拖 a WebPartManager control into the Content control.
2. Drag a RadioButtonList control onto the page, placing it below the WebPartManager control. In the RadioButtonList Tasks menu check Enable AutoPostBack, and then click Edit Items. In the ListItem Collection Editor dialog add the following items: "Browse", "Design", "Edit" and "Catalog". For "Browse" set the Selected property //是否选择属性to True, and then click OK. Set the control's ID property to "displayModeRadioButtonList", and RepeatDirection to Horizontal.
3. Double-click the RadioButtonList control to add a SelectedIndexChanged event handler事件处理器. To this handler add the following code, which sets the WebPartManager.DisplayMode property based on the user's RadioButtonList selection. It also causes a redirect//(页面)跳转 if the user is not logged in, because most of the Web Part display modes require authentication //确认(for the sake //缘故of Personalization):
| C# | VB | |
int selectedIndex = displayModeRadioButtonList.SelectedIndex;
if (!User.Identity.IsAuthenticated && selectedIndex > 0)
{
Response.Redirect("login.aspx?ReturnUrl=default.aspx");
}
switch (selectedIndex)
{
case 0:
WebPartManager1.DisplayMode = WebPartManager.BrowseDisplayMode;
break;
case 2:
WebPartManager1.DisplayMode = WebPartManager.EditDisplayMode;
break;
case 3:
WebPartManager1.DisplayMode = WebPartManager.CatalogDisplayMode;
break;
default:
WebPartManager1.DisplayMode = WebPartManager.DesignDisplayMode;
break;
}
|
||
4. Switch back //转换到to Design view. Select the Layout | Insert Table menu command to insert a single-row, three-column, 100% width table below the RadioButtonList control. Click Cell Properties and set the Vertical align property to top and Width to 33%.
5. Drag a WebPartZone control into the left cell. In its Properties window set ID to "leftColWebPartZone", and PartChromeType to BorderOnly. From the Solution Explorer, under Controls, drag LatestBlogs.ascx into the WebPartZone control.
6. Drag a second WebPartZone control into the middle cell of the table, setting its ID property to "midColWebPartZone".
7. Drag a CatalogZone control into the right cell of the table. Drag a DeclarativeCatalogPart control into the CatalogZoneControl. In the DeclarativeCatalogPart Tasks menu click Edit Templates. From the Solution Explorer, select both User Controls together and drag them into the DeclarativeCatalogPart control. Set the DeclarativeCatalogPart control's Title property //属性to "GeekBox"// 这句话没有弄明白是怎么回事.
8. Below the CatalogPart control drag an EditorZone control. Then, into this control drag an AppearanceEditorPart control.
9. In Source view remove//移除 the three style="width: 33%" statements //语句,陈述from the TD cells. These were used only to help your see the cells in Design view.
The Geek Speak sample application is now complete. Run it and create a new member account with a strong password (e.g., Pa$$word!), then enjoy all the robust//强壮的,强健的 features brought you by ASP.NET 2.0.
浙公网安备 33010602011771号