问题描述
我的 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!