Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 23rd, 2006, 10:41 AM
Authorized User
Points: 239, Level: 4
Points: 239, Level: 4 Points: 239, Level: 4 Points: 239, Level: 4
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jul 2005
Location: , , .
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)

Reply With Quote
  #2 (permalink)  
Old April 23rd, 2006, 11:33 AM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 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
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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

All times are GMT -4. The time now is 02:44 PM.

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