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 March 30th, 2009, 03:06 PM
Authorized User
 
Join Date: Mar 2009
Posts: 64
Thanks: 0
Thanked 1 Time in 1 Post
Default DisplayDirection not liked

On page 281, when I change from this line:

Code:
<Wrox:Banner ID="Banner1" runat="server" />
to this line

Code:
<Wrox:Banner ID="Banner1" runat="server" DisplayDirection="Horizontal" />
I get this error in the browser

Compiler Error Message: CS1061: 'System.ComponentModel.ISite' does not contain a definition for 'Classes' and no extension method 'Classes' accepting a first argument of type 'System.ComponentModel.ISite' could be found (are you missing a using directive or an assembly reference?)

I have my Direction.cs file in the directory Site.Classes.

Intellisense seems to know about DisplayDirection as it offers it as a property as well as the two values.

I am using C# and have included "using Site.Classes;" in MasterPage.Master.cs and Banner.ascx.cs.

If I simply remove the
DisplayDirection="Horizontal" from the control declaration in the MasterPage.Master the image will display in the browser horizontally.

I am missing something but cannot see it.

Thomas
 
Old March 30th, 2009, 03: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

>> have my Direction.cs file in the directory Site.Classes.

You keep referring to namespaces as folders., which is a bit confusing. Is it in the Site.Classes namespace, or do you have a folder called Site.Classes?

Also, is the DisplayDirection type recognized in the Code Behind of the User Control? I just ran a quick test in a Web Application Project and it works fine. o, few things to check:

1. namespace for the Enum

2. using statement in the UC to bring the enum in scope

3. @Register tag in the page using the UC

Also, make sure you don't have any compile errors in your site before you try this out.

Finally, I don't think that Site is a very good root namespace. Each page has a Site property that is used for design time purposes. Maybe that's causing the problem. Usually, I avoid these problems by using something like CompanyName.ProjectName.Layer as the root namespace. E.g. SomeCompany.CorporateSite.Web for a web project.

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 March 30th, 2009, 04:00 PM
Authorized User
 
Join Date: Mar 2009
Posts: 64
Thanks: 0
Thanked 1 Time in 1 Post
Default

Imar,

The top of my WAP solution is "Site". There is a folder under that called "Classes". Therein is "Direction.cs".

Within "Direction.cs" is the following:

Code:
namespace Site.Classes
{
    public enum Direction
    {
        Horizontal,
        Vertical
    }
}
Once I added "using Site.Classes" the the Code Behind for the User Control the type for "DisplayDirection" was recognized (the font changed to turquoise).

I have the "using Site.Classes;" statement in the User Control's code behind file.

I had in the previous "Try It Out" removed the "@ Register" from the Master page. The previous "Try It Out" worked as advertised.

There are no compile errors when I compile by keying F6.

I now understand that using "Site" was a poor choice. Everything has worked so far and I think changing it is a big deal.

Thanks.

Thomas
 
Old March 30th, 2009, 04:05 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

>> Everything has worked so far and I think changing it is a big deal.

Is it? A simple Find and Replace action should do the trick...

>> Once I added "using Site.Classes" the the Code Behind for the User Control the type for "DisplayDirection" was recognized

So is it working now?

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 March 30th, 2009, 04:22 PM
Authorized User
 
Join Date: Mar 2009
Posts: 64
Thanks: 0
Thanked 1 Time in 1 Post
Default

Quote:
Originally Posted by Imar View Post

>> Once I added "using Site.Classes" the the Code Behind for the User Control the type for "DisplayDirection" was recognized

So is it working now?

Imar
No. I have the using statement in the UC before I wrote the note. It works with

Code:
<Wrox:Banner ID="Banner1" runat="server" />
In MasterPage.Master, but not with

Code:
<Wrox:Banner ID="Banner1" runat="server" DisplayDirection="Horizontal" />
even though when I added "DisplayDirection" to the declaration Intellisense knew of it and aided it adding it.

Thomas
 
Old March 30th, 2009, 04:27 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

It might still be the Site problem. Have you tried renaming the namespace?

One way to test out how it's supposed to work (which is what I did) is to create a brand new WAP. Add the Enum, the UC and a page and you can see how things are supposed to work. Then you can "reverse engineer" your code and find the issue in your site.

Alternatively, you can send me a zipped version of the entire solution and I'll take a look.

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 March 30th, 2009, 04:35 PM
Authorized User
 
Join Date: Mar 2009
Posts: 64
Thanks: 0
Thanked 1 Time in 1 Post
Default

I will send you a zipped file of the solution and try the new, small WAP.

What is your e-mail address? I do not think I can send a file through the forum, can I?

Thomas
 
Old March 31st, 2009, 10:23 AM
Authorized User
 
Join Date: Mar 2009
Posts: 64
Thanks: 0
Thanked 1 Time in 1 Post
Default

Imar,

I can make this work if I dispense with the separate "Direction.cs" file in the "Site.Classes" namespace. Rather I created an Int32 with the name "DisplayDirection" in the "Banner.ascx.cs" file, and used the values of 0 and 1.

Interestingly, when I put the enum Direction in the "Banner.ascx.cs" file, before the "public partial class Banner : System.Web.UI.UserControl", but within the "namespace Site.Controls" I get the same old error. It is as if VS simply does not see the enum statement. The error now complains "Compiler Error Message: CS1061: 'System.ComponentModel.ISite' does not contain a definition for 'Controls' and no extension method 'Controls' accepting a first argument of type 'System.ComponentModel.ISite' could be found (are you missing a using directive or an assembly reference?)". Note its reference to "Controls".

I'd like to understand this since I know it will come up again in a project in the future.

Thanks.

Thomas

 
Old March 31st, 2009, 03:21 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 Thomas,

I renamed (site wide) the Site namespace to TestProject and everything worked fine.

Like I hinted earlier, Site is a more or less reserved word as the Page class has a Site property. Apparently, it has trouble keeping the two apart.

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 March 31st, 2009, 04:28 PM
Authorized User
 
Join Date: Mar 2009
Posts: 64
Thanks: 0
Thanked 1 Time in 1 Post
Default

Well I'll be danged! I just completely missed that in trying to interpret the error message. I changed it here and it worked immediately.

Thanks for your patience, Imar.

Thomas

Quote:
Originally Posted by Imar View Post
Hi Thomas,

I renamed (site wide) the Site namespace to TestProject and everything worked fine.

Like I hinted earlier, Site is a more or less reserved word as the Page class has a Site property. Apparently, it has trouble keeping the two apart.

Cheers,

Imar









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