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 June 27th, 2012, 07:13 PM
Registered User
 
Join Date: Jun 2012
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
Default Chapter 08: Creating Smarter User Controls

Using the C# version of the code.

I have created the Direction.cs with the enum Direction.

In /Controls/Banner.ascx.cs I get an error when entering "public Direction DisplayDirection { get; set; }". The app can't seem to find Direction.cs.

When I view Default.aspx in the browser it displays all right, but I get a compile error of

"Error 1 The type or namespace name 'Direction' could not be found (are you missing a using directive or an assembly reference?) C:\BegASPNETCS\Site\Controls\Banner.ascx.cs 10 10 C:\BegASPNETCS\Site\
"

So I seem to have missed a step somewhere but I'm darned if I can see it.

Thanks,

George
 
Old June 28th, 2012, 01:47 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

In which folder did you create the Direction enum? Can you post its code?

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!
 
Old June 28th, 2012, 08:43 AM
Registered User
 
Join Date: Jun 2012
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Direction.cs is in the App_Code folder. Here is the entirety of the code in the file.

Code:
public enum Direction
{
  Horizontal,
  Vertical
}
 
Old June 28th, 2012, 09:00 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

That looks OK to me.

Have you tried restarting VS? As explained in the book, the changes are not always picked up right away.

Also, are you sure you created a Web Site Project and not a Web Application project (the form has one code behind file for an ASPX; the latter has two).

If that doesn't help, can you post the code for the complete control as well as the page / master page where you use it?

Cheers,

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!
The Following User Says Thank You to Imar For This Useful Post:
huttog (June 28th, 2012)
 
Old June 28th, 2012, 02:39 PM
Registered User
 
Join Date: Jun 2012
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
Default Thanks!

Thank you for the quick response -- it is gratifying to see an author so readily available for questions.

Oddly enough, a restart of VS resolved the issue. When I initially created this I did wait five minutes for VS to pick up on the change but it never happened. Is there a different sort of build I should have asked for when bringing up the page?
 
Old June 29th, 2012, 03:16 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Quote:
Is there a different sort of build I should have asked for when bringing up the page?
You can force Visual Studio to compile the site. You can use Build | Build Website or right-click the site and choose Build Web site.

That should hopefully do the trick.

Cheers,

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!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 4, Creating Compound Controls example ejx002 BOOK: Professional Android Application Development ISBN: 978-0-470-34471-2 1 June 17th, 2009 08:32 AM
Ch.14 Creating Windows Form User Controls problem SAIFI BOOK: Beginning Microsoft Visual Basic 2008 ISBN: 978-0-470-19134-7 1 September 29th, 2008 05:51 AM
User controls' content: Chapter 2 User Controls AGS BOOK: Professional ASP.NET 2.0 Server Control and Component Development ISBN: 978-0-471-79350-2 10 July 26th, 2007 05:36 AM
Chapter 13 - Creating Your Own Custom Controls msjolin BOOK: Beginning VB.NET 2nd Edition/Beginning VB.NET 2003 2 February 16th, 2004 09:01 PM





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