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


基础教程推荐
- 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01
- JSON.NET 中基于属性的类型解析 2022-01-01
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01
- 错误“此流不支持搜索操作"在 C# 中 2022-01-01
- 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
- 全局 ASAX - 获取服务器名称 2022-01-01
- 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01
- 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01
- 首先创建代码,多对多,关联表中的附加字段 2022-01-01
- 如何动态获取文本框中datagridview列的总和 2022-01-01