I'm currently learning ASP and I'm struggling with an issue regarding inheritance with master pages, it stops me from being able to preview the page in a browser, VS 2017's design view limits me to just a static preview. I'm not asking for you to write the whole thing, but I'm not able to grasp where I've made a mistake, or if the instructions I'm following have an error. When I leave it as CodeBehind I get:
"Parser Error: BasePage' is not allowed here because it does not extend class 'System.Web.UI.Page"
If I change it to CodeFile I instead get this:
"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)."
This is the Default.aspx top thing
<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/MasterPages/Frontend.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Default.BasePage" %>
Default.aspx.cs looks like this:
namespace website05
{
public partial class Default : BasePage
{
protected void Page_Load(object sender, EventArgs e)
{
}
{
{
Also the BasePage.cs file is this:
namespace website05
{
public class BasePage : System.Web.UI.Page
{
private void Page_PreRender(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(this.Title) || this.Title.Equals("Untitled Page", StringComparison.CurrentCultureIgnoreCase))
{
throw new Exception("Page title cannot be \"Untitled Page\" or an empty string.");
}
}
public BasePage()
{
this.PreRender += Page_PreRender;
}
}
}
I apologise for the poor formatting, I've seen similar questions posted on here but the answers did not yield any results, I'm also very new to this and so I'm quite sure I may have misunderstood previous answers.
Put your page with namespace in the inherts-property in .aspx, like Inherits="website05.Default", don't use BasePage here.