Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Web Parts - ASP.NET 2.0

0 views
Skip to first unread message

RhondaT

unread,
Oct 7, 2008, 1:55:02 PM10/7/08
to
Working thru the 'step by step' book... Chpter 7. I even tried using the
sample code. (OK, I'm a VB person, not C#... but that shouldn't matter) For
some reason, the 'design' mode is NOT enabled... so when I run the page, my
dropdown list only contains 'browse'. If I over-ride the check, the 'design'
option shows in the list, but does not function properly. Setting the break
point shows that the design mode is not enabled... *where* is it not
enabled, and how do I enable it?

Thanks!

RhondaT

unread,
Oct 7, 2008, 2:10:00 PM10/7/08
to
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:DropDownList ID="DropDownListDisplayModes" runat="server"
AutoPostBack="True"

OnSelectedIndexChanged="DropDownListDisplayModes_SelectedIndexChanged">
</asp:DropDownList><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...

Gustavo Cantero

unread,
Oct 7, 2008, 2:14:13 PM10/7/08
to
Please post your code to see it and help you.

Gustavo A. Cantero
CEO - Scientia® Soluciones Informáticas
MCP - MCSD - MCTS
http://www.scientia.com.ar
http://www.programandoamedianoche.com
http://foro.scientia.com.ar

-----Mensaje original-----
De: RhondaT [mailto:Rho...@discussions.microsoft.com]
Expuesto a las: Martes, 07 de Octubre de 2008 02:55 p.m.
Expuesto en: microsoft.public.dotnet.framework.aspnet.webcontrols
Conversación: Web Parts - ASP.NET 2.0
Asunto: Web Parts - ASP.NET 2.0

RhondaT

unread,
Oct 7, 2008, 2:21:02 PM10/7/08
to
Done - I was doing so as you were asking. :-)

RhondaT

unread,
Oct 7, 2008, 7:00:03 PM10/7/08
to
Please see my post immediately preceeding yours... as I did post the code
(as an afterthought - sorry)

RhondaT

unread,
Oct 8, 2008, 12:19:13 PM10/8/08
to
I figured it out. While the book claims that you can jump in 'anwyhere',
Chapter 7 neglected to mention that the site had to be configured for
membership. I found a 'walkthrough' on MSDN
(http://msdn.microsoft.com/en-us/library/sk23dydw.aspx) ... and it made that
comment. once I did that, it worked just fine.
0 new messages