这里不允许,因为它没有扩展类'System.Web.UI.Page'。 [英] not allowed here because it does not extend class 'System.Web.UI.Page'.

查看:81
本文介绍了这里不允许,因为它没有扩展类'System.Web.UI.Page'。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hii,



'/'应用程序中的服务器错误。 
分析程序错误
描述:解析为此请求提供服务所需的资源时发生错误。请查看以下特定的解析错误详细信息并相应地修改源文件。

解析器错误消息:此处不允许使用'AddToCart',因为它不扩展类'System.Web.UI.Page'。

来源错误:


第1行:<%@ Page 语言 = C# AutoEventWireup = true 继承 = AddToCart Codebehind = AddToCart.aspx.cs %>
第2行:< !DOCT YPE html PUBLIC - // W3C // DTD < span class =code-attribute> XHTML 1.0 Transitional // EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd >
第3行:< html xmlns = http://www.w3.org/1999/xhtml\" >


源文件:/AddToCart.aspx行:1

版本信息:Microsoft .NET Framework版本:4.0.30319; ASP.NET版本:4.0.30319.18408







当我查看我的页面时,我收到了这个错误它继承自system.web.ui仍然是我收到此错误的原因..



请建议



 <%@       语言  =  C#    AutoEventWireup   =  true   继承  =  AddToCart    Codebehind   =  AddToCart.aspx.cs   %>  
< !DOCTYPE < span class =code-attribute> 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 = 服务器 >
< title > 添加到购物车页面< / title >
< / head > ;
< body >
添加到购物车...
< /正文 >
< / html >











 使用系统; 
使用 System.Collections.Generic;
使用 System.Linq;
使用 System.Web;
使用 System.Web.UI;
使用 System.Web.UI.WebControls;
使用 System.Data;
使用 System.Configuration;
使用 System.Collections;
使用 System.Web.Security;
使用 System.Web.UI.WebControls.WebParts;
使用 System.Web.UI.HtmlControls;
使用 BusinessLayer;

命名空间 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;
}
}

受保护 void Page_Load( object sender,EventArgs e)
{
int qty = 1 ; // 默认值为1,除非传递另一个值

if (请求[ qty]!= null
{
qty = int .Parse(Request [ qty]。ToString());
}
if (请求[ ProductId]!= null
{
SelectedInvoice.AddToInvoice( int .Parse(Request [ ProductId]。ToString()),qty) ;
}
Response.Redirect( ViewCart.aspx);
}
}
}

解决方案

1.Your AddToCart class(来自您的代码)在您的ASP页面中不可见,因为它是与应用程序默认名称不同的名称空间的一部分。



2.解决方案是指定类命名空间( PayPalDemo.AddToCart ),如下所示:

 < span class =code-pagedirective><%@     Page    语言  =  C#    AutoEventWireup   =  true   继承  =  PayPalDemo.AddToCart    Codebehind   =  AddToCart.aspx.cs    %GT;  


Hii ,

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

<%@ 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>






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");
        }
    }
}

解决方案

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:

<%@ Page Language="C#" AutoEventWireup="true" Inherits="PayPalDemo.AddToCart" Codebehind="AddToCart.aspx.cs" %>


这篇关于这里不允许,因为它没有扩展类'System.Web.UI.Page'。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆