tags:

views:

150

answers:

1

Hi All,

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

+2  A: 

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.

Matthew Jones
Thanks for the VB Update Rob!
Matthew Jones
@Matthew - no worries.. wasn't worth another answer
Rob Allen
aside: AutoEventWireup=true is a performance killer, you would be better off wiring the events explicitly in OnInit.
Sachin