Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 4.0 aka C# 2010 > BOOK: Beginning Visual C# 2010
|
BOOK: Beginning Visual C# 2010
This is the forum to discuss the Wrox book Beginning Visual C# 2010 by Karli Watson, Christian Nagel, Jacob Hammer Pedersen, Jon D. Reid, Morgan Skinner, ; ISBN: 9780470502266
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Visual C# 2010 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 April 12th, 2011, 11:27 PM
Registered User
 
Join Date: Apr 2011
Posts: 7
Thanks: 3
Thanked 0 Times in 0 Posts
Default Creating a strongly typed PreviousPage (p591)

On the Try It Out for Creating a strongly typed PreviousPage (p591), I'm getting the following error once I've typed in all the code:

Quote:
The type or namespace name 'RegistrationInfo' could not be found (are you missing a using directive or an assembly reference?)
in the files ResultsPage.aspx.cs and Registration.aspx.cs

I'm guessing that the files aren't 'seeing' the RegistrationInfo class that's been added. Any ideas on how to achieve this?

cobberas63
 
Old April 13th, 2011, 07:33 AM
Authorized User
 
Join Date: Dec 2004
Posts: 69
Thanks: 0
Thanked 5 Times in 5 Posts
Send a message via Yahoo to whiterainbow
Default

Where you added your RegistrationInfo Class? Whether you added it to a new class file that is having a different namespace? If so refer the namespace (using Namespace;)/access the class with fully typed name (Namespace.RegistrationInfo a=new Namespace.RegistrationInfo();) in the pages and your problem will be solved.
__________________
Thanks in advance.

Regards,

Senthil Kumar M.
The Following User Says Thank You to whiterainbow For This Useful Post:
cobberas63 (April 14th, 2011)
 
Old April 14th, 2011, 03:02 AM
Registered User
 
Join Date: Apr 2011
Posts: 7
Thanks: 3
Thanked 0 Times in 0 Posts
Default

None of the pages I created have a namespace definition the way the code samples have in the book, but they seem to work OK anyhow - I'm guessing that's because the files are all stored in the same folder (called ...\EventRegistrationWeb\) - is that correct?

When I first added the class (i.e. created the file RegistrationInfo.cs), the Visual Web Developer told me that new classes are usually stored in a folder called App_Code, and asked me if I wanted to create both the class & the folder. At first I said "no" and the class (i.e. RegistrationInfo.cs) sat in the same folder as all the other files - that's when I was getting the error.

Then I created the App_Code folder suggested by the Visual Web Developer and stored the class in there, and the application now works without error even without a namespace.

Is this an incorrect way of doing things?

Thanks for your help
cobberas63
 
Old April 14th, 2011, 03:24 AM
Authorized User
 
Join Date: Dec 2004
Posts: 69
Thanks: 0
Thanked 5 Times in 5 Posts
Send a message via Yahoo to whiterainbow
Default

Yes. When you are creating a website using the Visual Web Developer, the classes won't have any hierarchy or accessibility. When the code file is placed under the App_Code, the compiler will look into the folder to get the classes. If you are placing your code outside the App_Code folder you organize all your classes under strongly typed namespace but putting the code files outside the App_Code folder is not secure and so not advisable. So put the code files under the App_Code folder with namespace.

Happy Coding...
__________________
Thanks in advance.

Regards,

Senthil Kumar M.
The Following User Says Thank You to whiterainbow For This Useful Post:
cobberas63 (April 15th, 2011)
 
Old April 15th, 2011, 03:29 AM
Registered User
 
Join Date: Apr 2011
Posts: 7
Thanks: 3
Thanked 0 Times in 0 Posts
Default

Cool. Thanks heaps!
:-) C/





Similar Threads
Thread Thread Starter Forum Replies Last Post
strongly-typed DataSet.Rows r n't getting Updated srkvellanki ASP.NET 2.0 Professional 3 October 1st, 2008 05:26 PM
"Strongly typed" roman BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 2 June 26th, 2008 10:35 AM
Sorting Gridview bound to strongly typed object kulkarnimonica ASP.NET 2.0 Professional 10 September 20th, 2007 03:32 PM
Accessing Strongly Typed Session Data Woodman ASP.NET 2.0 Professional 2 March 9th, 2007 04:42 PM
Crystal Report and Strongly-Typed dataset jaucourt Crystal Reports 1 February 9th, 2004 07:39 AM





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