【发布时间】:2014-12-02 21:32:02
【问题描述】:
编辑:主要问题似乎是我只是将旧网站项目中的“添加现有项目”添加到 ASP.NET Web 应用程序项目中。这给我带来了很多麻烦,我只是从头开始,除了添加现有项目之外,我向项目添加了新的母版页和 aspx 页面,然后填充它们。同样的问题仍然存在。
我有一个遗留项目,它只是一个标准网站。我已经开始了一个作为 Web 应用程序的新项目,并且已经移植到我需要的所有页面中。但是,我收到了 100 多个错误,这些错误主要由以下略有不同的排列组成:
-
'System.Web.UI.MasterPage does not contain a definition for 'headerImage'(我在代码隐藏中得到了这个) -
'MasterPage' does not contain a definition for 'imgHeader'(这也在代码隐藏中)
关于第一个错误,好像项目不理解设置了母版页。我将母版页设置在每个 aspx 页面的顶部,例如:
<%@ page language="C#" masterpagefile="~/MasterPages/MasterPage.master" autoeventwireup="true" inherits="Equipment.aspx.cs" title="Untitled Page" %>
<%@ MasterType VirtualPath="~/MasterPages/MasterPage.master" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<!-- some content -->
</asp:Content>
另外,我在 ~/MasterPages/MasterPage.master 代码隐藏中明确公开了 headerImage 属性:
public partial class MasterPage : System.Web.UI.MasterPage
{
#region Properties
private string _headerImage;
public string headerImage
{
get
{
return _headerImage;
}
set
{
_headerImage = (string)value;
}
}
// other stuff
}
然而 VS 仍在 System.Web.UI.MasterPage 基类中寻找这个属性!
我已经查看了this 的帖子,但它并没有解决我的问题。
想法?感谢所有反馈。谢谢大家。
【问题讨论】:
-
这个文件“~/MasterPages/MasterPage.master”的分机在哪里
-
@DJKRAZE 我是 VS ASP.NET 的新手。如果你的意思是扩展,它只是 .master,后面的代码是 .cs。