Groups > Asp .Net > Advanced ASP.NET Architecture > Re: dead end: no suitable method found to override




dead end: no suitable method found to override

dead end: no suitable method found to override
Wed, 2 Apr 2008 09:55:17 +0000
Hey everyone..

I have several aspx pages. The codebehind files have quite similar code so I
wanted to put the code in one extra .cs file.
I called this class RequestHandler. Unfortunately C# doesn't feature multiple
inheritance (from classes) - and since every partial aspx page class inherits
from System.Web.UI.Page I cannot inherit from RequestHandler anymore. I solved
this problem by letting RequestHandler inherit from System.Web.UI.Page and my
aspx pages from RequestHandler.

Now I encounter the following error:
no suitable method found to override 

This compiler error occurs on a random basis. Sometimes for just one aspx page..
sometimes for several.
MSDN says: http://msdn2.microsoft.com/en-us/library/xb57z28f(VS.80).aspx

I do not have "override" nor "abstract" anywhere. And my
aspx page (class 2) inherits from RequestHandler (class 1)... isn't that good?
:-/
Post Reply
Re: dead end: no suitable method found to override
Wed, 2 Apr 2008 10:55:54 +0000
You need to include a (short) sample that shows this happening.
Post Reply
Re: dead end: no suitable method found to override
Wed, 2 Apr 2008 11:35:43 +0000
Yes.. probably I need to do that. However I don't want to confuse you.. ;-)

How would you (usually) solve my problem?
I couldn't really decide whether I want to write a class and pass all the
necessary parameters to its functions (like "Page", ...) or to let my
aspx pages inherit from a base class which provides the functionality. In every
aspx.cs class I have functions deciding what to do depending on the state the
page is currently in (on_load()..., updatepanel1_onPreRender()...). I want to
have these functions in one central place so I don't need to alter every .aspx
file in case I have to change something :-/
Post Reply
Re: dead end: no suitable method found to override
Wed, 2 Apr 2008 12:13:06 +0000
liga:How would you (usually) solve my problem? 

For this error: by examining the code at the line number referenced by the
error, and then the chain of base classes and implemented interfaces. 

There is really no other approach (unless you believe in fix by guess hope and
prayer).

 

More generally for "how to provide a common set of helpers to all my
pages", if a master page is not appropriate (not enough information in this
thread to know if that would be applicable), then a common application page type
as base for all .aspx pages or a helper class (i.e. composition) will really
depend on the details of the helpers (e.g. how much do they need to be able to
access private/protected state/methods vs. just context).
Post Reply
Re: dead end: no suitable method found to override
Wed, 2 Apr 2008 12:14:17 +0000
The usual approach in this scenario is to create a class that inherits from
System.Web.UI.Page, then inherit from that class in your code behind rather than
System.Web.UI.Page.

If you have an control with resuable functionality (updatepanel1_onPreRender()),
put that in a user control.

Alternatively, you could create a helper class with static functions.
Post Reply
<< Previous 1 2 3 Next >>
( Page 1 of 3 )
about | contact