aspx隐藏前台控件div_c# – 代码隐藏页面无法“查看”aspx页面中声明的任何项目/控件...

这是我的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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值