【发布时间】:2013-10-19 19:07:27
【问题描述】:
在使用 asp:hiddenfields 时我很困惑。
这是我的代码:
<asp:HiddenField ID ="CurrentAnswer" runat="server" Value="-1" />
并在该 html 页面中加载的 js 文件中:
$(document).ready(function () {
alert(document.getElementById("<%= CurrentAnswer.ClientID %>"));
});
此值返回 null。如果我将它放入同一个 asp webform 中,但不是放在单独的 js 文件中,它将起作用。我几乎在我查看的每个页面上都看到了这一点。 here 例如。我不知道为什么这不起作用。有什么想法吗?
【问题讨论】:
-
CurrentAnswer.ClientID 只能在 ASP 内部使用
-
这个页面有详细说明:[link]stackoverflow.com/questions/2027062/jquery-hidden-field[/link]
标签: jquery asp.net hidden-field