Click here to Skip to main content
15,884,388 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Hii ,

XML
Server Error in '/' Application.
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: 'AddToCart' is not allowed here because it does not extend class 'System.Web.UI.Page'.

Source Error:


Line 1:  <%@ Page Language="C#" AutoEventWireup="true" Inherits="AddToCart" Codebehind="AddToCart.aspx.cs" %>
Line 2:  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Line 3:  <html xmlns="http://www.w3.org/1999/xhtml" >


Source File: /AddToCart.aspx    Line: 1

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18408



I am getting this eror , when i check my page its inheritng from system.web.ui still why i am getting this error ..

Please suggest

XML
<%@ Page Language="C#" AutoEventWireup="true" Inherits="AddToCart" Codebehind="AddToCart.aspx.cs" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Add to Cart Page</title>
</head>
<body>
    Adding to cart ...
</body>
</html>





C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web.Security;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using BusinessLayer;

namespace PayPalDemo
{
    public partial class AddToCart : System.Web.UI.Page
    {
        private Invoice _selectedInvoice = new Invoice();
        public Invoice SelectedInvoice
        {
            get
            {
                if (_selectedInvoice.InvoiceId == "")
                {
                    try
                    {
                        _selectedInvoice = (Invoice)Session["Invoice"];
                    }
                    catch { }
                }
                return _selectedInvoice;
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            int qty = 1; //default is 1 unless pass in another value

            if (Request["qty"] != null)
            {
                qty = int.Parse(Request["qty"].ToString());
            }
            if (Request["ProductId"] != null)
            {
                SelectedInvoice.AddToInvoice(int.Parse(Request["ProductId"].ToString()), qty);
            }
            Response.Redirect("ViewCart.aspx");
        }
    }
}
Posted
Comments
Raul Iloc 22-Sep-14 8:09am    
Did you try like I suggested?

1 solution

1.Your AddToCart class (from your code behind) is not visible in your ASP page because is part of a namespace that is different then the application default one.

2.The solution is to specify also the class namespace (PayPalDemo.AddToCart) like bellow:
ASP.NET
<%@ Page Language="C#" AutoEventWireup="true" Inherits="PayPalDemo.AddToCart" Codebehind="AddToCart.aspx.cs" %>
 
Share this answer
 
v2
Comments
Torakami 23-Sep-14 1:29am    
Thanks man ..
Raul Iloc 23-Sep-14 1:32am    
So, did you manage to solve your problem by using my solution?
Torakami 23-Sep-14 2:27am    
not exactly as same , but adding namespaces for each classes ..your namespace concept helped me
Raul Iloc 23-Sep-14 3:28am    
I am glad that I could help you, so it will be nice from you to accept my solution!

PS: For any solution the idea for solving the problem is the most important, because I do not have your code to can test it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900