Jan Johansen
Jan Johansen

Reputation: 2059

Custom Page class

I'm trying to create a custom class for my pages in my project.

Here's the default.aspx.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : FrontPage
{
    public String text;
    protected void Page_Load(object sender, EventArgs e)
    {
        text = "";
    }
}

Here's the FrontPage class:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
/// Summary description for FrontPage
/// </summary>
public class FrontPage
{
    public DataContext db = new DataContext();
    public String a;
    //public void Page_Load(object sender, EventArgs e)
    //{        
    //}
}

The problem is I keep getting an error:

Make sure the class is defined in this kodefil corresponds to attribute 'inherits' and that it extends the correct base class (eg. Page or UserControl).

What am I doing wrong?

Upvotes: 1

Views: 367

Answers (1)

Kelsey
Kelsey

Reputation: 47736

Add to your definition for FrontPage:

public class FrontPage : System.Web.UI.Page

Your new class needs to inhierit from the basic 'Page' class.

Upvotes: 5

Related Questions