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
總結
以上是生活随笔為你收集整理的aspx隐藏前台控件div_c# – 代码隐藏页面无法“查看”aspx页面中声明的任何项目/控件...的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: RHCSA与RHCE红帽认证考试心得
- 下一篇: 前台jsp页面向后台传汉字出现乱码问题解