【问题标题】:Name does not exist in the current context ASP.NET当前上下文 ASP.NET 中不存在名称
【发布时间】:2011-05-12 20:07:00
【问题描述】:

我试图将输入类型文本中的值绑定到gridview,但我一直遇到错误“CS0103:当前上下文中不存在名称'dateborrowedTextBox'”

Date borrowed:
            <%--<asp:TextBox ID="dateborrowedTextBox" runat="server" 
                Text='<%# Bind("dateborrowed") %>' />--%>

            <%--date picker --%>
            <input type="text" runat="server" value='<%# Bind("dateborrowed") %>' name="dateborrowedTextBox" readonly="readonly" id="dateborrowedTextBox" /> 
            <a href="#" onclick="cdp1.showCalendar(this, '<%= dateborrowed.ClientID %>'); return false;">Date Picker</a>       
            <br />

那么如何在我的日期选择器中声明它?

我们将不胜感激。提前致谢。

【问题讨论】:

  • 您想将文本框的 ClientID 添加到 showCalendar-js-function 中吗?然后您还应该将'&lt;%= dateborrowed.ClientID %&gt;' 更改为'&lt;%= dateborrowedTextBox.ClientID %&gt;'。评论是因为这不完全是您要求答案的问题。

标签: c# asp.net


【解决方案1】:

您的文本框已被注释掉 - 更改

<%--<asp:TextBox ID="dateborrowedTextBox" runat="server" 
                Text='<%# Bind("dateborrowed") %>' />--%>

<asp:TextBox ID="dateborrowedTextBox" runat="server" 
                Text='<%# Bind("dateborrowed")%>' />

【讨论】:

  • 在 asp.net 文本框下面还有另外一个 input type="text" 这个ID。
  • 谢谢,但我仍然有同样的错误。看起来我必须在日期选择器中声明它。也很抱歉在发布我的错误之前忘记删除 cmets..
  • @Tim:谢谢,这就是为什么我必须评论 TextBox 控件。仍然找不到控件。无论如何我会再试一次..
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-03-30
  • 1970-01-01
  • 1970-01-01
  • 2013-10-02
  • 2014-04-22
  • 2017-06-17
相关资源
最近更新 更多