Wrox Programmer Forums
|
BOOK: Professional ASP.NET 3.5 : in C# and VB ISBN: 978-0-470-18757-9
This is the forum to discuss the Wrox book Professional ASP.NET 3.5: In C# and VB by Bill Evjen, Scott Hanselman, Devin Rader; ISBN: 9780470187579
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional ASP.NET 3.5 : in C# and VB ISBN: 978-0-470-18757-9 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 24th, 2010, 08:15 AM
Registered User
 
Join Date: Sep 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 17-WebPart error

Hi,

I am working on webparts development using your book. I am on Chapter 17 where you explain how to programatically add dropdown control to the page (C#). I have done everything as it says in the book but I am still getting the error message:

"The type or namespace name 'WebParts' could not be found (are you missing a using directive or an assembly reference?)"

Here is my default.aspx.cs file code:

Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.ComponentModel;

namespace TrainingWebApp
{
    public partial class _Default : System.Web.UI.Page
    {

    

    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
      WebParts.WebPartDisplayMode wpDisplayMode =
     WebPartManager1.SupportedDisplayModes[DropDownList1.SelectedValue.ToString()];
      WebPartManager1.DisplayMode = wpDisplayMode;
    }

    protected void Page_Init(object sender, EventArgs e)
    {
      foreach (WebPartDisplayMode wpMode in 
         WebPartManager1.SupportedDisplayModes)
      {            
            string modeName = wpMode.Name;
            ListItem dd_ListItem = new ListItem(modeName, modeName);
            DropDownList1.Items.Add(dd_ListItem);
      }
    }
}

}
And this is my Default.aspx file:

Code:
<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeBehind="Default.aspx.cs" Inherits="TrainingWebApp._Default" %>
    <%@ Register Src="~/DailyLinks.ascx" TagName="DailyLinks" TagPrefix="uc1" %>

    
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
    <style type="text/css">
        .style1
        {
            width: 100%;
            border-style: solid;
            border-width: 1px;
        }
    </style>
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    <h2>
        Welcome
    </h2>
    
    <p>
        Web Parts Page</p>
    <asp:WebPartManager ID="WebPartManager1" runat="server">
    </asp:WebPartManager>
        <div>
     
    <form id="form1" runat="server">
        <asp:WebPartManager ID="Webpartmanager2" Runat="server">
        </asp:WebPartManager>
        <table cellpadding="5" border="1">
            <tr>
                <td colspan="2">
                    <h1>My Web Page</h1>
                    <asp:WebPartZone ID="WebPartZone1" Runat="server" 
                     LayoutOrientation="Horizontal">
                        <ZoneTemplate>
                            <asp:Label ID="Label1" Runat="server" Text="Label" 
                             Title="Welcome to my web page!">
                             Welcome to the page!
                            </asp:Label>
                        </ZoneTemplate>
                    </asp:WebPartZone>
                </td>
                <td valign="top">
                    Select mode:
                    <asp:DropDownList ID="DropDownList1" runat="server" 
                     AutoPostBack="True" 
                     OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">        
                    </asp:DropDownList>
                </td>
            </tr>
            <tr valign="top">
                <td>
                    <asp:WebPartZone ID="WebPartZone2" Runat="server">
                        <ZoneTemplate>
                            <asp:Image ID="Image1" Runat="server" 
                             ImageUrl="~/Images/coin2.jpg" Width="150px" 
                             Title="Tuija at the Museum">
                            </asp:Image>
                            <uc1:DailyLinks ID="DailyLinks1" runat="server" 
                             Title="Daily Links">
                            </uc1:DailyLinks>
                        </ZoneTemplate>
                    </asp:WebPartZone>
                </td>
                <td>
                    <asp:WebPartZone ID="WebPartZone3" Runat="server">
                        <ZoneTemplate>
                            <asp:Calendar ID="Calendar1" Runat="server"
                             Title="Calendar">
                            </asp:Calendar>
                        </ZoneTemplate>
                    </asp:WebPartZone>
                </td>
                <td><!-- Blank for now -->
                </td>
            </tr>
        </table>        
    </form>

        </div>

</asp:Content>
Please let me know what am I doing wrong?

Thank you.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Gridview Chapter 17 error Kelv BOOK: Beginning Visual Basic 2005 ISBN: 978-0-7645-7401-6 1 February 19th, 2009 11:49 AM
Error in Sharepoint Webpart subhasps8 SharePoint Development 0 May 19th, 2008 04:17 AM
Error code: Chapter 17 Pag 576 luisxvarg BOOK: Beginning Visual Basic 2005 ISBN: 978-0-7645-7401-6 1 October 15th, 2007 08:06 PM
Chapter 17 First Try It Out paloyme BOOK: Beginning Visual Basic 2005 ISBN: 978-0-7645-7401-6 7 August 23rd, 2006 11:14 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.