Inheritance Problem when trying to implement Page Controller

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

Michael Lang

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().

It should be complaining that you have 2 methods of the same method
signature in the abstract class... both called "SomeMethod()". If it is
not complaining with the exact code you've shown, then it should be. It
may think you are overriding the SomeMethod() that is not marked as
"MustOverride"

If these are not the actual method signatures in each class, then show us
the real ones.
 
J

John Saunders

Michael Lang said:
It should be complaining that you have 2 methods of the same method
signature in the abstract class... both called "SomeMethod()". If it is
not complaining with the exact code you've shown, then it should be. It
may think you are overriding the SomeMethod() that is not marked as
"MustOverride"

Michael, I don't see two different "SomeMethod" methods. Could you point
them out, please?
 
J

Jon Skeet

Michael Lang said:
The following was in the original posted code...
====================================
SomeMethod()

End Sub

Public MustOverride Sub SomeMethod()

End Class
====================================

Yes, but that first SomeMethod() is a call to the second one, isn't it?
It's within the Page_Load method.

I don't really know VB.NET, but it certainly looks to me like there's
only one declaration of SomeMethod() there...
 
M

Michael Lang

Yes, but that first SomeMethod() is a call to the second one, isn't it?
It's within the Page_Load method.

I don't really know VB.NET, but it certainly looks to me like there's
only one declaration of SomeMethod() there...

Oops. Since it wasn't indented I read it wrong. Also, I'm used to looking
at C# code. I depend on those curly braces and proper indentation to keep
me from getting lost.
 

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

Top