这是我的Default.aspx页面(删除了不必要的细节):
Username | |
Password | |
这是代码隐藏(删除了不必要的细节):
namespace webapp
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
(webapp.MasterPages.MasterPage)Page.Master).headerImage = "default";
this.Master.headerImage = "default";
if (!Page.IsPostBack)
{
this.pnlInvalidCredentials.Visible = false; // error is here
this.BindPressRoomItem();
}
}
}
}
这个页面/代码隐藏是顶级的,它不是任何文件夹或任何东西.此项目也是一个ASP.NET Web应用程序,它从遗留的Web站点项目中借用代码.我没有“添加现有”到任何文件,所有文件都是“添加新”以防止兼容性问题.试过this,没用.
在代码隐藏中,每次尝试操作aspx页面中声明的项都会导致如下错误:
‘_Default’ does not contain a definition for ‘pnlInvalidCredentials’
要么
The name ‘txtUsername’ does not exist in this context.
解决方法:
由于我刷新了这个页面,你已经删除了html文件顶部的page指令行,但看起来你可能需要包含命名空间.
尝试:
Inherits =“webapp._Default”而不是Inherits =“_ Default”
标签:c,net,asp-net,compiler-errors,code-behind
来源: https://codeday.me/bug/20190609/1208414.html