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 January 23rd, 2012, 08:32 PM
Friend of Wrox
 
Join Date: May 2011
Posts: 411
Thanks: 13
Thanked 7 Times in 7 Posts
Default Error Message

When doing the examples in your book on pages 284-287 I get the following message in my errors category:

Message 1 Validation (ASP.Net): Attribute 'DisplayDirection' is not a valid attribute of element 'Banner'. C:\Wrox Beginning ASP.NET4.0\Source\Chapter 07\MasterPages\Frontend.master 38 50 C:\...\Chapter 07\
 
Old January 27th, 2012, 08:46 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,

Did you define the enum in the App_Code folder and did you create a public property in the Code Behind of the User Control? And have you tried rebuilding the site (Ctrl+Shift+B) and / or reopening Visual Studio?

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 7th, 2012, 05:24 PM
Registered User
 
Join Date: Jun 2012
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
Default I am having a problem getting my site to build sucessfully

I keep getting an error "CS0246: The type or namespace name 'BasePage' could not be found." This appears to come from a call to function the BasePage function in the BasePage.cs file in the App_Code Folder how do I inform Visual Studio Professional where the function is so that the referance can be found?

Thanks,
Clay
 
Old June 7th, 2012, 05:41 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 Clay,

Where did you save the BasePage file? In which folder? And can you post the code of the file that generates the error?

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 7th, 2012, 07:18 PM
Registered User
 
Join Date: Jun 2012
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
Default Error Message

This is one of the referances in Default.aspx.cs (the code behind file) this appearing in several different files.

Code:
public partial class _Default : BasePage
{
  protected void Page_Load(object sender, EventArgs e)
  {

  }
}
The function call (or whaterver that function call looking thing is) is in the /App_Code Folder/BasePage.cs since I did not create it I think it was put in automatically. That code is as follows:
Code:
namespace BegASPCS.App_Code
{
    public class BasePage : System.Web.UI.Page
    {
        private void Page_PreInit(object sender, EventArgs e)
        {
            HttpCookie preferredTheme = Request.Cookies.Get("PreferredTheme");
            if (preferredTheme != null)
            {
                Page.Theme = preferredTheme.Value;
            }
        }

        private void Page_PreRender(object sender, EventArgs e)
        {
            if(this.Title == "Untitled Page" || string.IsNullOrEmpty(this.Title))
            {
                throw new Exception("Page cannot be \"Untitled Page\" or an empty string");
            }
        }
         public BasePage()
        {
            this.PreRender += new EventHandler(Page_PreRender);
            this.PreInit += new EventHandler(Page_PreInit);
        }
    }
}
The function does some sort of page initializeation and appends values to the current objects that are referanced in the first function by the functions above the calling function. The C# files that use the function are unable to referance \App_Code\BasePage.cs.
 
Old June 8th, 2012, 09:43 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:
since I did not create it I think it was put in automatically.
I doubt that; The BasePage does not exist in .NET by itself, and is added in an exercise in the book.

Quote:
namespace BegASPCS.App_Code
{
How did the namespace get there? It looks like you chose the wrong project type (that is, a Web Application Project and not a Web Site Project). If that's the case, many examples won't work as shown in the book (for example, because a WAP does not support the App_Code folder).

Can you confirm your ASPX pages have two code behind files, one with Designer in its name?

For now, you may get away with it by changing

: BasePage

to

: BegASPCS.App_Code.BasePage

in the code behind of your pages.

Quote:
The function does some sort of page initializeation and appends values to the current objects that are referanced in the first function by the functions above the calling function. The C# files that use the function are unable to referance \App_Code\BasePage.cs.
Not everything is a function in JavaScript. You may want to (re)read chapters 5 and 6 so you get a better understanding of the terminology and what this code does.

Cheers,

Imar


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:
ClayWeblogistics (June 8th, 2012)
 
Old June 8th, 2012, 06:27 PM
Registered User
 
Join Date: Jun 2012
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
Default Build Error

Yesterday I was frusterated and I could see the code and it was not making the connection I saw the event handlers and it just was not connecting. I am going to try your suggestions and work it again.

Thanks for the help,
Clay
 
Old June 8th, 2012, 06:49 PM
Registered User
 
Join Date: Jun 2012
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
Default

It does have a designer page as well as a code behind page. Is that an indication that it is a Web Application Project versus a Web Site Project the controls in Visual Studio Professional looked a lot different than VWD. Would I be better off starting with a Web Site Project? and Deleting the Web Application Project?

Just wondering,
Clay
 
Old June 9th, 2012, 05:07 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 that an indication that it is a Web Application Project versus a Web Site Project
Yes, you've chosen a Web Application indeed. Take a look at Chapter 2, pages 34-35 and 37-38 in particular.

You can grab the source from the Wrox site and use the code from the chapter before the one you're currently working on as a starting point.

Quote:
the controls in Visual Studio Professional looked a lot different than VWD.
That shouldn't be the case; they should be the same. What kind of differences are you seeing?

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
Error Message Mind Games BOOK: Beginning Visual C# 2010 3 July 21st, 2011 12:33 PM
What is the error message for a 500 server error? chobo2 C# 2005 1 May 4th, 2008 03:11 AM
Error message radconchuck ASP.NET 1.0 and 1.1 Basics 0 July 3rd, 2007 01:13 PM
Error Message: renodays ASP.NET 1.0 and 1.1 Basics 2 April 1st, 2004 11:09 AM
??? about error message g_dub96 VB.NET 2002/2003 Basics 0 October 13th, 2003 01:09 PM





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