Can#39;t access control ID in code behind(无法在后面的代码中访问控制 ID)
问题描述
我的 aspx 页面中有以下代码:
I have the following code in my aspx page:
<asp:Button runat="server" ID="myButton" Text="hello" />
这在我后面的代码中:
protected void Page_Load(object sender, EventArgs e)
{
myButton.Text = "bye";
}
由于某种原因,intellisense 会在后面的代码中获取myButton" id,但是当它编译时会显示
For some reason the intellisense picks up the "myButton" id in the code behind but when it compiles it says
它无法构建,因为它无法识别它!
it can't build because it doesn't recognise it!
我的页面是使用母版页的默认 aspx 页面,按钮位于内容控件内,并且所有设置为在服务器上正确运行,页面运行并显示正常,除了此按钮分辨率问题!
My page is a default aspx page which uses a master page, the button is inside a content control and all is set to run at server correctly, the page runs and displays fine except for this button resolution issue!
有什么想法吗?
推荐答案
听起来您的设计器文件 (PageName.designer.cs) 有点乱了.我会尝试从您的页面中删除该按钮并重新添加.
Sounds like your designer file (PageName.designer.cs) has got a bit messed up. I'd try deleting the button from your page and adding it again.
这篇关于无法在后面的代码中访问控制 ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:无法在后面的代码中访问控制 ID
基础教程推荐
- 将 Office 安装到 Windows 容器 (servercore:ltsc2019) 失败,错误代码为 17002 2022-01-01
- 为什么Flurl.Http DownloadFileAsync/Http客户端GetAsync需要 2022-09-30
- SSE 浮点算术是否可重现? 2022-01-01
- 将 XML 转换为通用列表 2022-01-01
- rabbitmq 的 REST API 2022-01-01
- c# Math.Sqrt 实现 2022-01-01
- 有没有办法忽略 2GB 文件上传的 maxRequestLength 限制? 2022-01-01
- 如何激活MC67中的红灯 2022-01-01
- MS Visual Studio .NET 的替代品 2022-01-01
- 如何在 IDE 中获取 Xamarin Studio C# 输出? 2022-01-01