Wrox Programmer Forums
|
BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0
This is the forum to discuss the Wrox book ASP.NET 2.0 Website Programming: Problem - Design - Solution by Marco Bellinaso; ISBN: 9780764584640
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 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 October 17th, 2006, 08:43 AM
Registered User
 
Join Date: Oct 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default ThemeSelector class error

This error has me stuck in Chapter 2

In the ThemeSelector.ascx.cs file:

...
using System.Web.UI.HtmlControls;
using MB.TheBeerHouse;


namespace MB.TheBeerHouse.UI.Controls
{
    public partial class ThemeSelector : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, System.EventArgs e)
        {

....
...
I keep getting this error that somehow I cannot eliminate:

Compiler Error Message: ASPNET: Make sure that the class defined in this code file matches the 'inherits' attribute, and that it extends the correct base class (e.g. Page or UserControl).

Even when I have in my Template.master:

<%@ Master Language="C#" AutoEventWireup="true" %>
<%@ Register Src="Controls/ThemeSelector.ascx" TagName="ThemeSelector" TagPrefix="mb" %>

and in my ThemeSelector.ascx Control:
<%@ Control Language="C#" AutoEventWireUp="true" Inherits="ThemeSelector" CodeFile="ThemeSelector.ascx.cs"%>

Does anybody bump into something similar before?

Any help will be very much appreciated

Thanks --xrica32
 
Old October 17th, 2006, 10:17 AM
Authorized User
 
Join Date: May 2006
Posts: 99
Thanks: 0
Thanked 1 Time in 1 Post
Default

Whenever you use a namespace in a code behind class you must be sure to specify it in your inherits attribute of the aspx or acsx code. So the change to make is this:
<%@ Control Language="C#" AutoEventWireUp="true" Inherits="MB.TheBeerHouse.UI.Controls.ThemeSelecto r" CodeFile="ThemeSelector.ascx.cs"%>

Marco does use namespaces throughout the code, but doesn't indicate it in the book.

 
Old October 17th, 2006, 10:45 AM
Registered User
 
Join Date: Oct 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you so much!
I am new to ASP.NET and you guys are extremely helpful.

-xrica32
 
Old August 8th, 2007, 11:01 AM
Registered User
 
Join Date: Aug 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I've updated the 'inherit code' to follow the namespace. I also have:

using MB.TheBeerHouse.UI;

... In the ThemeSelector.ascx.cs file. I get the same error. Did I miss something else small?

So .. the ThemeSelector.ascx has:

<%@ Control Language="C#" AutoEventWireup="true" Inherits="MB.TheBeerHouse.UI.ThemeSelector" CodeFile="ThemeSelector.ascx.cs" %>


The ThemeSelector.ascx.cs file has:

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using MB.TheBeerHouse.UI;


public partial class ThemeSelector : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        ddlThemes.DataSource = Helpers.GetThemes();
        ddlThemes.DataBind();

        ddlThemes.SelectedValue = this.Page.Theme;
    }

}


Don't quite get it. Moving on to chapter 3 all the same ... but would like to get my head around why this isn't working. Any further ideas?

(At times like this, Perl seems so simple! :P )
 
Old August 14th, 2007, 08:20 PM
Authorized User
 
Join Date: Jun 2007
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello Jwasp,
Try these changes, add Bold text and remove Strikethrough text as shown below:

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using MB.TheBeerHouse<s>.UI</s>;

namespace MB.TheBeerHouse.UI.Controls
{

public partial class ThemeSelector : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        ddlThemes.DataSource = Helpers.GetThemes();
        ddlThemes.DataBind();

        ddlThemes.SelectedValue = this.Page.Theme;
    }

}
}

for the .aspx page:

<%@ Control Language="C#" AutoEventWireup="true" Inherits="MB.TheBeerHouse.UI.Controls.ThemeSelector" CodeFile="ThemeSelector.ascx.cs" %>

Good luck,

http://www.cspringsboard.com








Similar Threads
Thread Thread Starter Forum Replies Last Post
HEADS-UP: Error in Article class Lee Dumond BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 3 May 1st, 2008 11:28 PM
Using class reference getting error rojiin ASP.NET 2.0 Basics 2 July 6th, 2007 01:53 PM
Chapter 2 ThemeSelector - Puzzled Porjung BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 2 June 11th, 2007 07:43 AM
Document Class pointer error bluebeta Visual C++ 3 July 5th, 2006 05:10 AM
error ... when calling a class HumaMunir Java Espanol 2 May 7th, 2005 01:09 PM





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