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.
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.
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
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <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_SelectedIndexChanged);
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load);
All that I can think of:
1. Is the code file that you posted in the same application virtual as the aspx file?
2. Is that code in the productcatalog.aspx.cs file? (Normally it would be named WebForm1.aspx.cs)
Jazzcatone
Member
254 Points
84 Posts
Inheritance Problems
Apr 23, 2006 03:36 PM|LINK
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,
Jason
-----------------------------------------------------------------------------------------------------
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)
{
BindGrid();
}
}
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;
DataGrid1.DataBind();
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <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_SelectedIndexChanged);
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void DataGrid1_SelectedIndexChanged(object sender, System.EventArgs e)
{
ArrayList arr;
if (Session["mycart"] != null)
{
arr = (ArrayList)Session["mycart"];
}
else
{
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;
arr.Add(item);
}
private void Button1_Click(object sender, System.EventArgs e)
{
Response.Redirect("cart.aspx");
}
}
}
NC01
All-Star
82577 Points
15430 Posts
MVP
Re: Inheritance Problems
Apr 23, 2006 04:10 PM|LINK
All that I can think of:
1. Is the code file that you posted in the same application virtual as the aspx file?
2. Is that code in the productcatalog.aspx.cs file? (Normally it would be named WebForm1.aspx.cs)
NC...