0

我正在尝试在页面指令上设置一个自定义属性“ 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 继承。

4

1 回答 1

1

这不是 Page 指令的工作方式。您甚至在解析页面之前就要求它理解您的派生类。

你应该把它Page_Init()放在Manager_Info_services.

于 2013-06-27T21:42:36.823 回答