为什么我的所有ASP.NET元素引用都未定义?

时间:2011-09-10 18:40:02

标签: c# .net asp.net

由于某些原因,我不知道我的.aspx.cs中的所有元素引用都是未定义的。例如:
在MyPage.aspx中,我有<asp:TextBox runat="server" ID="UserName" />,在MyPage.aspx.cs中我UserName.Text="abc"。然后在构建之后我得到一个sais错误:The name 'UserName' does not exist in the current context

enter image description here

即使在我的Global.asax中,我收到的错误是字符无法识别: enter image description here

我真的不知道它是什么,可能是我的命名空间或类似的东西。但正如我所见 - 所有名称空间都是正确的 我该如何解决这些错误?

1 个答案:

答案 0 :(得分:0)

如果您已从其他项目添加了一些* .aspx和* .ascx文件,请检查* .aspx.designer.cs和* .aspx.cs文件的构建操作是否设置为compile。 / p>

相关问题