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):
Dim selectedIndex As Integer = displayModeRadioButtonList.SelectedIndex
If Not User.Identity.IsAuthenticated AndAlso selectedIndex > 0 Then
Response.Redirect("login.aspx?ReturnUrl=default.aspx")
End If
Select Case selectedIndex
Case 0
WebPartManager1.DisplayMode = WebPartManager.BrowseDisplayMode
Case 2
WebPartManager1.DisplayMode = WebPartManager.EditDisplayMode
Case 3
WebPartManager1.DisplayMode = WebPartManager.CatalogDisplayMode
Case Else
WebPartManager1.DisplayMode = WebPartManager.DesignDisplayMode
End Select
VB
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.