1

I write base class,MyBase.cs, for asp.net pages. I want all asp.net page inherit from that base class instead of System.Web.UI.Page. So i configure in web.config as mention below.

<pages pageBaseType="MyBase">

Then i got following error message.

Make sure that the class defined in this code file matches the 'inherits' attribute, and that it extends the correct base class (e.g. Page or UserControl)

Please help what shoul i do? do i need to inherits MyBase to every aspx pages.

My Web App running on .Net Framework 3.5SP1 & VS 2008

Thanks

1 Answer 1

2

In your ASPX page, the first line should have an Inherits attribute. In your code behind, the first line of the class should be something like

//C#
public partial class NameOfPage : NameOfYourInheritedPageClass

//VB.Net
Partial Class NameOfPage
    Inherits NameOfYourInheritedPageClass

Make sure that the NameOfPage matches the target of the Inherits attribute.

Also make sure the AutoEventWireup="true" and CodeFile points to the corresponding code-behind file.

2
  • @Matthew - no worries.. wasn't worth another answer
    – Rob Allen
    Jun 10, 2009 at 16:57
  • aside: AutoEventWireup=true is a performance killer, you would be better off wiring the events explicitly in OnInit.
    – Sachin
    Jun 10, 2009 at 16:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.