Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3
This is the forum to discuss the Wrox book Beginning ASP.NET 3.5: In C# and VB by Imar Spaanjaars; ISBN: 9780470187593
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 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 December 18th, 2009, 04:32 PM
Registered User
 
Join Date: Dec 2009
Posts: 5
Thanks: 2
Thanked 0 Times in 0 Posts
Default Chapter 8: User Controls: Page 281

When attempting update of control declaration on page 281, this line

Code:
   <Wrox:Banner ID="Banner1" runat="server" />
has green line under "Banner" and claims:

Code:
  Element 'Banner' is not a known element....
My web.config file has:

Code:
  <pages theme="Monochrome" >
   <controls>
     <add tagPrefix="Wrox" tagName="Banner" src="~/Controls/Banner.ascx"/>
   </controls>
  </pages>
What am I missing? I've stepped through this a couple of times.
Thanks, Mark
 
Old December 18th, 2009, 04:39 PM
Registered User
 
Join Date: Dec 2009
Posts: 5
Thanks: 2
Thanked 0 Times in 0 Posts
Default Code Behind from Banner.ascx.cs

Here is the code behind from the control, Banner.ascx.cs

Code:
public partial class Controls_Banner : System.Web.UI.UserControl
{
	protected void Page_Load(object sender, EventArgs e)
	{
		pnlHorizontal.Visible = false;
		pnlVertical.Visible = false;

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

	public Direction DisplayDirection { get; set; }


}
 
Old December 18th, 2009, 04:46 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi Mark,

Is the .ascx file indeed called Banner.ascx and located in the Controls folder? Is Controls located at the root of the site in the Solution Explorer? Is the Direction enum defined correct and does everything compile? (Choose Build | Build Web Site to test that out).

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!
 
Old December 18th, 2009, 05:12 PM
Registered User
 
Join Date: Dec 2009
Posts: 5
Thanks: 2
Thanked 0 Times in 0 Posts
Default

filename: Banner.ascx in folder: /Controls off the root.

Direction.cs has only this text:

Code:
public enum Direction
{
	Horizontal,
	Vertical
}
Here are the errors when I try to compile:
Code:
Warning	2	Element 'Banner' is not a known element. This can occur if there is a compilation error in the Web site, or the web.config file is missing.	Z:\idm\idmwebdev\MasterPages\MasterPage.master	40	10	Z:\idm\idmwebdev\
Error	3	'Controls_Banner.DisplayDirection.get' must declare a body because it is not marked abstract or extern	Z:\idm\idmwebdev\Controls\Banner.ascx.cs	30	38	Z:\idm\idmwebdev\
Error	4	'Controls_Banner.DisplayDirection.set' must declare a body because it is not marked abstract or extern	Z:\idm\idmwebdev\Controls\Banner.ascx.cs	30	43	Z:\idm\idmwebdev\
Error	5	z:\idm\idmwebdev\Controls\Banner.ascx.cs(30): error CS0501: 'Controls_Banner.DisplayDirection.get' must declare a body because it is not marked abstract or extern
Should this work under .NET 2.0?
 
Old December 18th, 2009, 05:23 PM
Registered User
 
Join Date: Dec 2009
Posts: 5
Thanks: 2
Thanked 0 Times in 0 Posts
Default

OK, I think the problem is .NET 3.5. My web server hasn't been upgrade yet, so I was working as .NET 2.0.

All working well now.

Thanks much, and thanks for the book. Very good and giving one to a friend for Christmas.
 
Old December 19th, 2009, 05:09 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:
Thanks much, and thanks for the book. Very good and giving one to a friend for Christmas
Excellent. Good to hear you got it resolved, and even better to hear you like the book so much ;-)

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 8: User Controls - Shows all banners VeganMan BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 1 April 9th, 2008 03:45 PM
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
how can i access controls on parent page from user marvz ASP.NET 2.0 Basics 0 September 5th, 2005 11:18 PM
User controls not showing on web page pdr ASP.NET 1.0 and 1.1 Basics 0 August 10th, 2005 09:02 AM
Multiple user controls on a page kriskramer General .NET 2 September 14th, 2004 08:42 AM





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