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
基础教程推荐
- .NET SerialPort DataReceived 事件未触发 2022-01-01
- 禁止输入少量字符,例如'<'、'&a 2022-01-01
- WPF 模态进度窗口 2022-01-01
- 如果有人提交恶意软件Nuget包怎么办? 2022-01-01
- C# 从 List<List<int>> 中删除重 2022-01-01
- 当值可以是对象或空数组时反序列化 JSON 2022-01-01
- 如何使用 .Net 检查 Active Directory 服务器是否已启动并正在运行? 2022-01-01
- 我应该在后面的代码中直接使用 Linq To SQL 还是使 2022-01-01
- Azure Functions:CosmosDBTrigger 未在 Visual Studio 中触发 2022-01-01
- Moq It.Is<>不匹配 2022-01-01
