简体   繁体   中英

asp.net c# codefile not working properly

I am trying to add a codefile to my asp.net masterpage. I had it working properly on an individual page, but cannot do so on my master page.

In my aspx master page I have:

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="Master.cs" Inherits="Master.Master" %>

Then I have a file called:

Master.cs

and the code below is:

namespace Master
{
    using System;

    public partial class Master : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.Write("ALEX");
            Response.End();
        }
    }
}

as far as I can see all my declarations are correct, but the error I get is:

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).

and the line:

Line 5:      public partial class Master : System.Web.UI.Page

is in red. I have had this error before but I am sure I have all my code correctly, so am not sure why I m getting this error?

Maybe the master file needs a different setup, or it works differently on the masterpage?

在类后面定义母版页代码时,要继承的基类是System.Web.UI.MasterPage ,而不是System.Web.UI.Page

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM