【发布时间】:2013-03-05 06:24:42
【问题描述】:
我有一个<asp:menu/> 控件和一个隐藏字段。现在我正在使用 jQuery 来更改隐藏字段的值。
代码是:-
$(function() {
$(".primaryStaticMenu tr,td").each(function(index) {
$(this).click(function() {
if ($(this).attr("title") != "undefined"
&& $(this).attr("title").length > 0) {
document.getElementById('ctl00_Hidden_Master_Location').value = $(this).attr("title");
alert(document.getElementById('ctl00_Hidden_Master_Location').value);
//return false;
}
});
});
});
获取更新值的服务器端代码是:-
string Get_cng_value = Hidden_Master_Location.Value;
但是Hidden_Master_Location.Value 每次都显示null。
谁能告诉我如何从后面的代码中获取隐藏字段的更新值。
【问题讨论】:
-
请提供隐藏字段的aspx页面代码
-
这一行在浏览器中提示什么? alert(document.getElementById('ctl00_Hidden_Master_Location').value);
-
我是 jquery 的新手,但是隐藏字段的 id 是
ctl00_Hidden_Master_Location,不应该在服务器代码中使用它来引用它而不是Hidden_Master_Location.Value? -
除了服务器端代码之外,还显示了您如何向服务器提交数据(您的问题中缺少该部分脚本/HTML)。
-
试试:
document.getElementById(<%=Hidden_Master_Location.ClientId%>.value);
标签: c# javascript jquery asp.net