Inheritance Problem

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..
 
B

Binod Nair

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
 
J

John Saunders

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,740
Latest member
JudsonFrie

Latest Threads

Top