【发布时间】:2015-05-27 20:06:16
【问题描述】:
我正在尝试将代码文件添加到我的 asp.net 母版页。我让它在单个页面上正常工作,但不能在我的母版页上这样做。
在我的 aspx 母版页中,我有:
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="Master.cs" Inherits="Master.Master" %>
然后我有一个文件名为:
Master.cs
下面的代码是:
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
为红色。我之前遇到过这个错误,但我确定我的所有代码都是正确的,所以不知道为什么会出现这个错误?
也许主文件需要不同的设置,或者它在主页面上的工作方式不同?
【问题讨论】: