perhaps this might help in the discussion :
default.aspx code:
<%@ Page Language="VB" AutoEventWireup="true" CodeFile="Default.aspx.vb"
Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="
http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:WebPartManager ID="WebPartManager1" runat="server">
</asp:WebPartManager>
<asp:Label ID="Label1" runat="server" Text="Switch Display
Mode:"></asp:Label><br />
<asp
ropDownList ID="DropDownListDisplayModes" runat="server"
AutoPostBack="True"
OnSelectedIndexChanged="DropDownListDisplayModes_SelectedIndexChanged">
</asp
ropDownList><br />
</div>
<asp:WebPartZone ID="WebPartZoneLinks" runat="server"
BorderColor="#CCCCCC" Font-Names="Verdana"
HeaderText="Links" Padding="6" Width="223px">
<EmptyZoneTextStyle Font-Size="0.8em" />
<PartStyle Font-Size="0.8em" ForeColor="#333333" />
<TitleBarVerbStyle Font-Size="0.6em" Font-Underline="False"
ForeColor="White" />
<MenuLabelHoverStyle ForeColor="#E2DED6" />
<MenuPopupStyle BackColor="#5D7B9D" BorderColor="#CCCCCC"
BorderWidth="1px" Font-Names="Verdana"
Font-Size="0.6em" />
<MenuVerbStyle BorderColor="#5D7B9D" BorderStyle="Solid"
BorderWidth="1px" ForeColor="White" />
<PartTitleStyle BackColor="#5D7B9D" Font-Bold="True"
Font-Size="0.8em" ForeColor="White" />
<ZoneTemplate>
<asp:HyperLink ID="HyperLink1" runat="server"
NavigateUrl="
http://msdn.mirosoft.com">MSDN</asp:HyperLink>
<asp:HyperLink ID="HyperLink2" runat="server"
NavigateUrl="
http://www.syncfusioin.com">Syncfusion</asp:HyperLink>
<asp:HyperLink ID="HyperLink3" runat="server"
NavigateUrl="
http://www.microsoft.com">Microsoft</asp:HyperLink>
</ZoneTemplate>
<MenuVerbHoverStyle BackColor="#F7F6F3" BorderColor="#CCCCCC"
BorderStyle="Solid"
BorderWidth="1px" ForeColor="#333333" />
<PartChromeStyle BackColor="#F7F6F3" BorderColor="#E2DED6"
Font-Names="Verdana" ForeColor="White" />
<HeaderStyle Font-Size="0.7em" ForeColor="Blue"
HorizontalAlign="Center" />
<MenuLabelStyle ForeColor="White" />
</asp:WebPartZone>
</form>
</body>
</html>
default.aspx.vb code:
Partial Class _Default
Inherits System.Web.UI.Page
Private _wpManager As WebPartManager
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
End Sub
Private Sub Page_Init(ByVal sender As Object, ByVal e As EventArgs)
' original code
' Page.InitComplete += New EventHandler(InitializationComplete)
' VB version below:
AddHandler Page.InitComplete, New EventHandler(AddressOf
InitializationComplete)
End Sub
Public Sub InitializationComplete(ByVal sender As Object, ByVal e As
System.EventArgs)
_wpManager = WebPartManager.GetCurrentWebPartManager(Page)
Dim browseModeName As String
Dim mode As WebPartDisplayMode
Dim i As Integer
browseModeName = WebPartManager.BrowseDisplayMode.Name
Dim nModes As Integer = _wpManager.SupportedDisplayModes.Count
For i = 0 To nModes - 1
mode = _wpManager.SupportedDisplayModes.Item(i)
Dim modeName As String
modeName = mode.Name
' Make sure a mode is enabled before adding it.
If (mode.IsEnabled(_wpManager)) Then
Dim item As ListItem = New ListItem(modeName, modeName)
Me.DropDownListDisplayModes.Items.Add(item)
End If
Next i
End Sub
Protected Sub DropDownListDisplayModes_SelectedIndexChanged(ByVal sender
As Object, ByVal e As System.EventArgs) Handles
DropDownListDisplayModes.SelectedIndexChanged
Dim selectedMode As String
selectedMode = DropDownListDisplayModes.SelectedValue
Dim mode As WebPartDisplayMode
mode = _wpManager.SupportedDisplayModes([selectedMode])
If (Not (mode Is Nothing)) Then
_wpManager.DisplayMode = mode
End If
End Sub
Private Sub Page_PreRender(ByVal sender As Object, ByVal e As EventArgs)
Dim items As ListItemCollection
items = Me.DropDownListDisplayModes.Items
Dim selectedIndex As Integer
selectedIndex =
items.IndexOf(items.FindByText(_wpManager.DisplayMode.Name))
DropDownListDisplayModes.SelectedIndex = selectedIndex
End Sub
End Class
That's it... but for some reason, the 'design' option does NOT appear in the
drop down. Ideas?
For clarification, the book I'm working with is ASP.NET 2.0 Step by Step by
George Shepherd... ISBN 0-7356-2201-9 : and no, there isn't anything
regarding this issue in the errata stuff...