【问题标题】:Error:The name 'you' does not exist in the current context错误:当前上下文中不存在名称“您”
【发布时间】:2012-03-06 07:18:45
【问题描述】:

我的编码有问题。有一个错误是:

错误:当前上下文中不存在名称“您”。 该 ID 已存在于 Default.aspx 中

<asp:DropDownList ID="you" runat="server">
           <asp:ListItem>zed</asp:ListItem>
           <asp:ListItem>joey</asp:ListItem>
           <asp:ListItem>john</asp:ListItem>

和 Default.aspx.cs

string stat = you.SelectedValue.ToString();

但是当我调试程序时,它说内容中不存在“你”。为什么会出现此错误,我该如何解决?

【问题讨论】:

  • 可能是你定义了另一个同名控件
  • 您是通过 IDE 的 GUI 添加控件还是输入控件?
  • 你能发布更多你的代码吗? aspx 和 aspx.cs

标签: asp.net c#-4.0


【解决方案1】:

你的结束标签在哪里。 &lt;/asp:DropDownList&gt;.它的工作完美。我试试看。

【讨论】:

  • 哎呀。对不起,我忘了把 放在问题中。
  • 没问题。没有任何错误 P:) 运行完美。我试试看。可能是您的controlpagebehind 文件不同,请仔细查看。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-06-01
  • 2010-12-17
  • 2019-01-16
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多