asp.net c#代码文件工作不正常
我正在尝试将代码文件添加到asp.net母版页。我让它在单个页面上正常工作,但无法在母版页上正常工作 在我的aspx母版页中,我有:asp.net c#代码文件工作不正常,c#,asp.net,C#,Asp.net,我正在尝试将代码文件添加到asp.net母版页。我让它在单个页面上正常工作,但无法在母版页上正常工作 在我的aspx母版页中,我有: <%@ Master Language="C#" AutoEventWireup="true" CodeFile="Master.cs" Inherits="Master.Master" %> 代码如下: namespace Master { using System; public partial class Master : S
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="Master.cs" Inherits="Master.Master" %>
代码如下:
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();
}
}
}
据我所知,我所有的声明都是正确的,但我得到的错误是:
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).
这句话:
Line 5: public partial class Master : System.Web.UI.Page
它是红色的。我以前有过这个错误,但我确信我所有的代码都是正确的,所以我不确定为什么会出现这个错误
可能主文件需要不同的设置,或者它在母版页上的工作方式不同 定义母版页代码隐藏类时,要继承的基类是
System.Web.UI.MasterPage
,而不是System.Web.UI.page
Line 5: public partial class Master : System.Web.UI.Page