Wrox Programmer Forums
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics 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 23rd, 2006, 10:41 AM
Authorized User
Join Date: Jul 2005
Posts: 43
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem With Inheritance

  Hello and thank you for taking a moment to read this message.The practice of inheritance is something as a developer I am still struggling with a little bit. I have a page called productcatalog.aspx. It contains the following line of code.

<%@ Page language="c#" Codebehind="productcatalog.aspx.cs" AutoEventWireup="false" Inherits="ShoppingCartCookies.WebForm1" %>
Everytime I go to compile VS 2005 throws me the following build error:

Error 2 Could not load type'ShoppingCartCookies.WebForm1'. C:\Documents and Settings\Jason Livengood\My Documents\Visual Studio 2005\WebSites\WebSite8\productcatalog.aspx 1

I was wondering if anybody could tell me where my mistake is. I would appreciate any help anybody can give. Below is my codebehind for the page.

Thank You,


using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

namespace ShoppingCartCookies
    public class WebForm1 : System.Web.UI.Page

        protected System.Web.UI.WebControls.Button Button1;
        protected System.Web.UI.WebControls.DataGrid DataGrid1;

        private void Page_Load(object sender, System.EventArgs e)
            if (!Page.IsPostBack)

        private void BindGrid()
            SqlDataAdapter da = new SqlDataAdapter("select * from products", @"data source=.\vsdotnet;initial catalog=northwind;user id=sa");
            DataSet ds = new DataSet();
            da.Fill(ds, "products");

            DataGrid1.DataSource = ds;

        #region Web Form Designer generated code
        override protected void OnInit(EventArgs e)
            // CODEGEN: This call is required by the ASP.NET Web Form Designer.

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
            this.DataGrid1.SelectedIndexChanged += new System.EventHandler(this.DataGrid1_SelectedIndexCh anged);
            this.Button1.Click += new System.EventHandler(this.Button1_Click);
            this.Load += new System.EventHandler(this.Page_Load);


        private void DataGrid1_SelectedIndexChanged(object sender, System.EventArgs e)
            ArrayList arr;
            if (Session["mycart"] != null)
                arr = (ArrayList)Session["mycart"];
                arr = new ArrayList();
                Session["mycart"] = arr;

            CShoppingCartItem item = new CShoppingCartItem();
            item.ProductID = int.Parse(DataGrid1.SelectedItem.Cells[1].Text);
            item.ProductName = DataGrid1.SelectedItem.Cells[2].Text;
            item.UnitPrice = decimal.Parse(DataGrid1.SelectedItem.Cells[3].Text);
            item.Quantity = 1;

        private void Button1_Click(object sender, System.EventArgs e)

Old April 23rd, 2006, 11:33 AM
Imar's Avatar
Wrox Author
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts

Hi there,

This is code from a ASP.NET 1.x page, which will not run as is on 2005

For example, you need to change the page directive attribute of Codebehind to CodeFile. There may be more errors though. The easiest things is to create a new page in VS 2005, and then manually copy the relevant parts from the old page to the new page. Alternatively, you can use the upgrade wizard to upgrade your old site to VS 2005 / .NET 2 format.


Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004

Similar Threads
Thread Thread Starter Forum Replies Last Post
inheritance problem kaos_frack BOOK: Professional JavaScript for Web Developers ISBN: 978-0-7645-7908-0 1 March 25th, 2007 09:28 AM
Inheritance problem flyin General .NET 2 May 20th, 2004 10:55 AM
c# inheritance bhohman C# 2 March 26th, 2004 01:47 PM
Vectors/inheritance problem hpy_gilmore8 C++ Programming 1 February 23rd, 2004 08:21 PM

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