Inheritance Problem

  • Thread starter Thread starter Binod Nair
  • Start date Start date
B

Binod Nair

Hi All,

Can somebody tell me what I am doing wrong.

I have a Base Abstract Class

Public MustInherit Class BaseRequestHandler : Inherits System.Web.UI.Page

Protected Overridable Sub Page_Load(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles MyBase.Load

SomeMethod()

End Sub

Public MustOverride Sub SomeMethod()

End Class

I have a Web Page which Inherits this base class

Public Class ManageCatalog : Inherits BaseRequestHandler

Public Overrides Sub SomeMethod()

'Code Block

end sub

end class

When I try to run it , I get the error

Compiler Error Message: BC30610: Class 'ManageCatalog_aspx' must either be
declared 'MustInherit' or override the following inherited 'MustOverride'
member(s): Public Overridable MustOverride Sub SomeMethod().





Plss Help.. I am doing something really stupid..
 
John thanks a lot

The problem was here

I HAD IT AS
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb"
Inherits="TestVBWebApp.BaseRequestHandler "%>

AND NOT LIKE WHAT John said
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb"
Inherits="TestVBWebApp.WebForm1"%>

It doesnt make sense to me why it needs to be like this ..Shouldnt it be
like the way i had declared..

John can u share ur thoughts about this.Also can u give an example when the
inherits value in "<%@ Page Language.." is going to be different.

--binod
 
Binod Nair said:
John thanks a lot

The problem was here

I HAD IT AS
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb"
Inherits="TestVBWebApp.BaseRequestHandler "%>

AND NOT LIKE WHAT John said
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb"
Inherits="TestVBWebApp.WebForm1"%>

It doesnt make sense to me why it needs to be like this ..Shouldnt it be
like the way i had declared..

John can u share ur thoughts about this.Also can u give an example when the
inherits value in "<%@ Page Language.." is going to be different.

Here's the way it "normally" works when a CodeBehind page is used. You've
got page WebForm1.aspx. This is parsed and compiled into a class with a
generated name, like, ASPX_WebForm1. This class inherits from the class
mentioned in the Inherits attribute in the Page directive.

WebForm1.aspx.vb contains your codebehind class. It would declare a class
called WebForm1 in the TestVBWebApp namespace. The WebForm1 class inherits
from System.Web.UI.Page. So you have the following:

ASPX_WebForm1 ==> TestVBWebApp.WebForm1 ==> System.Web.UI.Page

An example of when this would be different is in the case where codebehind
is not used. In that case, the Inherits attribute says
Inherits="System.Web.UI.Page". That is:

ASPX_WebForm1 ==> System.Web.UI.Page

As an example of when the Inherits in the codebehind would be different is a
situation like yours:

ASPX_WebForm1 ==> TestVBWebApp.WebForm1 ==> TestVBWebApp.BaseRequestHandler
==> System.Web.UI.Page

Note that in this case, you still need the Inherits="TestVBWebApp.WebForm1",
since that's the class which ASPX_WebForm1 inherits directly from.
 
Back
Top