Wrox Programmer Forums
|
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 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 October 16th, 2010, 06:33 PM
Authorized User
Points: 267, Level: 5
Points: 267, Level: 5 Points: 267, Level: 5 Points: 267, Level: 5
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2010
Posts: 56
Thanks: 17
Thanked 2 Times in 2 Posts
Default Ch8 Problem in Banner.ascx.cs

I'm up to page 285 and I'm getting two errors as described below.
Any clues?
Thanks
Ken


There is a red line underneath the term "Direction" in the line:

Code:
public Direction DisplayDirection { get; set; }
The error message says
"The type or namespace could not be found"

Note: I have created the "Direction.cs" file in the App_Code folder


ALSO
there is a red line under the term "DisplayDirection" in the line
Code:
      switch (DisplayDirection)
The error message says:
"A switch expression or case label must be a bool,char,string,integral,enum or corresponding nullable type."

Here is the complete code for Banner.ascs.cs
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;
      }

    }
}

Last edited by ken evans; October 16th, 2010 at 06:35 PM.. Reason: typo
 
Old October 17th, 2010, 06:19 AM
Authorized User
Points: 267, Level: 5
Points: 267, Level: 5 Points: 267, Level: 5 Points: 267, Level: 5
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2010
Posts: 56
Thanks: 17
Thanked 2 Times in 2 Posts
Default

OK - problem "gone away".
I have no idea what caused this problem but after restarting my machine it's no longer there.
For other reasons, I also uninstalled and re-installed IE8.

Wierd but all is now well.
Ken
 
Old October 17th, 2010, 07:32 AM
Authorized User
 
Join Date: Jul 2010
Posts: 81
Thanks: 10
Thanked 3 Times in 2 Posts
Default

Quote:
Originally Posted by ken evans View Post
OK - problem "gone away".
I have no idea what caused this problem but after restarting my machine it's no longer there.
For other reasons, I also uninstalled and re-installed IE8.

Wierd but all is now well.
Ken
I tried to mimic your problem, Ken, but couldn't get it to occur. I am reviewing some info since I have taken a month off of study ASP.NET.

ONE thing Imar mentions in his book is to close files and re-open, sometimes necessary to refresh. Rebooting did that I'm sure.
__________________
Bob
bdtcomp.com
http://lettersfromasoldier.com
Follow me on Twitter
“Success is not final, failure is not fatal: it is the courage to continue that counts.”~Winston Churchill

Last edited by btcomp; October 17th, 2010 at 09:11 PM..
 
Old March 29th, 2011, 09:18 PM
Registered User
 
Join Date: Mar 2011
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
Default Restarting VWD seems to be the key

I ran into this same problem. Closing all the files and reopening them didn't solve it, but restarting VWD 2010 Express did the trick. It's as though VWD didn't notice I'd added Direction.cs to App_Code until after the restart.
 
Old March 29th, 2011, 09:28 PM
Authorized User
 
Join Date: Jul 2010
Posts: 81
Thanks: 10
Thanked 3 Times in 2 Posts
Default

Quote:
Originally Posted by jtcours View Post
I ran into this same problem. Closing all the files and reopening them didn't solve it, but restarting VWD 2010 Express did the trick. It's as though VWD didn't notice I'd added Direction.cs to App_Code until after the restart.
Interesting. That seems to be true sometimes of many Windows programs. And of course rebooting sometimes is necessary. On really busy computer days, what day isn't, I have found myself rebooting several times in one day. I just figure the busier I am, the memory gets lost in the shuffle. Rebooting, and even occasionally a complete shutdown and then wait a minute and then reboot, I guess I'm just old school on this.

Then there is Linux, where I hear you don't have to reboot!?!
__________________
Bob
bdtcomp.com
http://lettersfromasoldier.com
Follow me on Twitter
“Success is not final, failure is not fatal: it is the courage to continue that counts.”~Winston Churchill
 
Old March 29th, 2011, 09:34 PM
Registered User
 
Join Date: Mar 2011
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
Default

The fact that not everyone runs into the problem smells a bit like a race condition. Maybe if you do things in exactly the wrong order, or with the wrong timing, or all the stars align just right, VWD gets confused.

As for Linux, yep, reboots are rare.





Similar Threads
Thread Thread Starter Forum Replies Last Post
RssReader.ascx.cs error mwalker BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 4 April 16th, 2007 04:14 AM
ascx page problem RPG SEARCH ASP.NET 1.0 and 1.1 Basics 1 November 8th, 2005 08:12 PM
Context.User in siteheader.ascx.cs scottf BOOK: ASP.NET Website Programming Problem-Design-Solution 7 November 3rd, 2005 12:52 PM
ch8 problem cylo JSP Basics 3 July 19th, 2004 02:40 AM
Cannot compile siteheader.ascx.cs golfvilla BOOK: ASP.NET Website Programming Problem-Design-Solution 6 January 19th, 2004 06:27 PM





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