C# App_Data class not inherited by aspx - inherits attribute question

3.1k Views Asked by At

I have been trying to figure this out for a while now and even though there are plenty of Google results for the error message I receive the solution eludes me. I think that I am doing what I am supposed to be doing.

VS2010, I created a common.cs in App_Data. The content of common.cs are functions which will be used by all pages. As far as I can tell this is the proper way to share code-behind code among multiple pages.

App_Data\common.cs

namespace nprah
{
    public class BasePage : System.Web.UI.Page
    {
    }
{

fish-creek.aspx.cs

namespace nprah
{
    public partial class Fishck : BasePage
    {
    }
}

fish-creek.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="fish-creek.aspx.cs" Inherits="nprah.BasePage" %>  

If I understand the Inherits attribute correctly then it does need to contain the NameSpace.ClassName, which mine does. See: http://support.microsoft.com/kb/312311

When I run this code it results in the following output:

Compiler Error Message: ASPNET: 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).

Source Error:

Line 11: {
Line 12:
Line 13: public partial class Fishck : BasePage
Line 14: {
Line 15:

Visual Studio is not showing any errors during the design. Any guidance you may be able to provide will be much appreciated. Thanks in advance.

1

There are 1 best solutions below

2
On BEST ANSWER

In your ASPX it should be

Inherits="nprah.Fishck"

Inherits in your .aspx should be mapping to your code file(.cs)... and from there your codefile will inherit your basepage like you already did.

And also try to validate that : CodeFile="fish-creek.aspx.cs". Because with the name of the file you supplied it should be : Codefile="fishck.aspx.cs". Maybe just a typo.