解析@page指令上的属性时出错

时间:2013-06-27 21:31:35

标签: asp.net vb.net

我正试图在页面指令上设置自定义属性“ DisableBrowserCache ”,如此

<%@ Page Language="VB" AutoEventWireup="false"  DisableBrowserCache="True"
 CodeFile="Info-services.aspx.vb" Inherits="Manager_Info_services" %>

这是继承链

Partial Class Manager_Info_services
Inherits EltApp.ELTPage
'Code
End Class


Namespace EltApp
Public Class ELTPage
    Inherits System.Web.UI.Page

    Public Property DisableBrowserCache() As Boolean
        Get
            Return _DisableBrowserCache
        End Get
        Set(value As Boolean)
            _DisableBrowserCache = value
        End Set
    End Property
End Class End Namespace

正如您所看到的,我继承自继承自System.Web.UI.Page的类。这个问题是在指令上设置属性会给我以下错误

System.Web.HttpParseException (0x80004005):
    Error parsing attribute 'disablebrowsercache': 
    Type 'System.Web.UI.Page' does not have a public property named 'disablebrowsercache'. 
---> system.Web.HttpParseException (0x80004005): 
    Error parsing attribute 'disablebrowsercache':
    Type 'System.Web.UI.Page' does not have a public property named 'disablebrowsercache'.
---> System.Web.HttpException (0x80004005):
    Error parsing attribute 'disablebrowsercache':
    Type 'System.Web.UI.Page' does not have a public property named 'disablebrowsercache'.
   at System.Web.UI.TemplateParser.ProcessError(String message)
   at System.Web.UI.TemplateControlParser.ProcessUnknownMainDirectiveAttribute(String filter, String attribName, String value)

我有一种感觉,因为我不直接从代码隐藏文件中的System.Web.UI.Page继承。

1 个答案:

答案 0 :(得分:1)

这不是Page指令的工作方式。即使在解析页面之前,您也要求它理解您的派生类。

您应该将其置于Page_Init()的{​​{1}}事件中。