Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4 > BOOK: Beginning ASP.NET 4 : in C# and VB
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning ASP.NET 4 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4: in C# and VB by Imar Spaanjaars; ISBN: 9780470502211
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4 : in C# and VB section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 25th, 2013, 12:05 PM
Registered User
Points: 12, Level: 1
Points: 12, Level: 1 Points: 12, Level: 1 Points: 12, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2013
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
Default Try-it-out on p.284. Refuses to recognize DisplayDirection

Hello
I'm working on the Try-it-out on p.284 ("Creating Smarter User Controls").
I followed the directions to the letter, and VWD refuses to recognize DisplayDirection on Banner.ascx.cs The error keeps popping up saying "A switch expression or case label must be a bool, char, string, integral, enum, or corresponding nullable type". I really a appreciate your help

First, my Direction class:
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
/// Summary description for Direction
/// </summary>
public class Direction
{
public enum Direction
{
Horizontal,
Vertical

}


}



Second, here is my code-behind for my Banner control:
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Controls_Banner : System.Web.UI.UserControl
{
public Direction DisplayDirection { get; set; }

protected void Page_Load(object sender, EventArgs e)
{
HorizontalPanel.Visible = false;
VerticalPanel.Visible = false;


switch (DisplayDirection)
{
case Direction.Horizontal:
HorizontalPanel.Visible = true;
break;
case Direction.Vertical:
VerticalPanel.Visible = true;
break;
}

}

}
Next, the markup for the banner control:
Code:
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="Banner.ascx.cs" Inherits="Controls_Banner" %>
<asp:Panel ID="VerticalPanel" runat="server">
<a href="http://p2p.wrox.com" target="_blank">
<asp:Image ID="Image1" runat="server" AlternateText="This is a sample banner"
ImageUrl="~/Images/Banner120x240.gif" />
</a>
</asp:Panel>

<asp:Panel ID="HorizontalPanel" runat="server">
<a href="http://p2p.wrox.com" target="_blank">
<asp:Image ID="Image2" runat="server" AlternateText="This is a sample banner"
ImageUrl="~/Images/Banner468x60.gif" />
</a>
</asp:Panel>


And this is the master page's code:

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="Frontend.master.cs" Inherits="MasterPages_Frontend" %>


<!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></title>
<asp:ContentPlaceHolder id="head" runat="server">
</asp:ContentPlaceHolder>

</head>
<body>
<form id="form1" runat="server">
<div id="PageWrapper">
<div id="Header"><a href="~/" runat="server">Header Goes Here</a></div>
</div>
<div id="MenuWrapper">
<asp:Menu ID="Menu1" runat="server" CssClass="MainMenu"
DataSourceID="SiteMapDataSource1" Orientation="Horizontal"
StaticEnableDefaultPopOutImage="False">
</asp:Menu>
<asp:TreeView ID="TreeView1" runat="server" DataSourceID="SiteMapDataSource1"
ShowExpandCollapse="False">
<LevelStyles>
<asp:TreeNodeStyle CssClass="FirstLevelMenuItems" />
</LevelStyles>
</asp:TreeView>
<asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server"
ShowStartingNode="False" />
</div>
<div id="MainContent">
<asp:SiteMapPath ID="SiteMapPath1" runat="server">
</asp:SiteMapPath> <br /><br/>
<asp:ContentPlaceHolder ID="cpMainContent" runat="server">
</asp:ContentPlaceHolder>
</div>
<div id="Sidebar">
Select Theme<br />
<asp:DropDownList ID="ThemeList" runat="server" AutoPostBack="True"
Height="16px" Width="140px">
<asp:ListItem>Monochrome</asp:ListItem>
<asp:ListItem>DarkGrey</asp:ListItem>
</asp:DropDownList>

<br />
<br />
<Wrox:Banner ID="Banner1" runat="server" />
<br />
<br />
<br />
<br />

</div>
<div id="Footer">Footer Goes Here</div>

</form>
</body>
</html>
Reply With Quote
  #2 (permalink)  
Old March 25th, 2013, 04:50 PM
Authorized User
Points: 45, Level: 1
Points: 45, Level: 1 Points: 45, Level: 1 Points: 45, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2012
Posts: 12
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Hi Danay!

I'm having the exact same problem with the exact same exercise (lol). I don't know when Imar will be back. He's been gone for like a week now. Are you doing yours in C#, like me? I'm gonna try the VB version and see what happens. Sorry I couldn't be of any help.

GreenhornPup
Reply With Quote
  #3 (permalink)  
Old March 26th, 2013, 11:44 AM
Imar's Avatar
Wrox Author
Points: 72,038, Level: 100
Points: 72,038, Level: 100 Points: 72,038, Level: 100 Points: 72,038, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,080
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Hi there,

Take a look at this:

Code:
public class Direction
{
    public enum Direction
    { 
        Horizontal,
        Vertical
    
    }
   
  
}
You have nested the enum inside a class, which is not the correct way to do it. Remove the wrapping class and I think it should work:

Code:
public enum Direction
    { 
           Horizontal,
           Vertical
    }
Hope this helps,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote
The Following User Says Thank You to Imar For This Useful Post:
danay2013 (March 28th, 2013)
  #4 (permalink)  
Old March 28th, 2013, 10:13 AM
Registered User
Points: 12, Level: 1
Points: 12, Level: 1 Points: 12, Level: 1 Points: 12, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2013
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
Default thanks

Thanks Imar your answer fix the problem, that are the commun mistakes of the beginners
Reply With Quote
  #5 (permalink)  
Old March 28th, 2013, 10:14 AM
Registered User
Points: 12, Level: 1
Points: 12, Level: 1 Points: 12, Level: 1 Points: 12, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2013
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Take a look to Imar's answer ....
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Try-it-out on p. 284 - DisplayDirection not recognized GreenhornPup BOOK: Beginning ASP.NET 4 : in C# and VB 4 March 26th, 2013 01:11 PM
Errata Lesson 23 pg.284 RMADANAT BOOK: Stephens' C# Programming with Visual Studio 2010 24-Hour Trainer 1 February 2nd, 2012 03:16 PM
Chapter 8 p 284-287 wrighwj BOOK: Beginning ASP.NET 4 : in C# and VB 1 September 3rd, 2011 08:30 AM
DisplayDirection not liked member4953 BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 10 April 1st, 2009 03:16 AM
refuses to centre a graphic cat CSS Cascading Style Sheets 5 November 6th, 2004 10:54 AM



All times are GMT -4. The time now is 11:54 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.