I have an <asp:menu/>
control and a hidden field.Now i am using jQuery to change value of hidden field. Code is:-
我有一个
$(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;
}
});
});
});
Server side code to get updated value is:-
获取更新值的服务器端代码是: -
string Get_cng_value = Hidden_Master_Location.Value;
But Hidden_Master_Location.Value
shows null
every time. can any one tell me how to get updated value of hidden field from code behind.
但是Hidden_Master_Location.Value每次都显示为null。任何人都可以告诉我如何从后面的代码中获取隐藏字段的更新值。
2 个解决方案
#1
1
Let say your hidden field is as..
让我们说你隐藏的领域是......
<asp:HiddenField ID="Hidden_Master_Location" runat="server" />
you can get the value of hidden filed in jquery as
你可以在jquery中得到隐藏字段的值
var locationValue= $("#<%= Hidden_Master_Location.ClientID %>").val();
#2
0
Do this, it works for me.the trick is to save your hidden field precious id in another hidden input field then build it back using that hidden value.
这样做,它适用于我。诀窍是将您隐藏的字段珍贵id保存在另一个隐藏的输入字段中,然后使用该隐藏值重新构建它。
Markup
标记
<asp:HiddenField ID="HiddenFieldMaster" runat="server" />
<input type="hidden" id="inputHidden" value='<%= HiddenFieldMaster.ClientID%>' />
Javascript
使用Javascript
$(function() {
$(".primaryStaticMenu tr,td").each(function(index) {
$(this).click(function() {
if ($(this).attr("title") != "undefined"
&& $(this).attr("title").length > 0) {
var inputHidden = document.getElementById('inputHidden');
$("#" + inputHidden.value).val($(this).attr("title"));
alert(inputHidden.value);
//return false;
}
});
});
});
Code Behind
代码背后
String Get_cng_value = HiddenFieldMaster.Value;
#1
1
Let say your hidden field is as..
让我们说你隐藏的领域是......
<asp:HiddenField ID="Hidden_Master_Location" runat="server" />
you can get the value of hidden filed in jquery as
你可以在jquery中得到隐藏字段的值
var locationValue= $("#<%= Hidden_Master_Location.ClientID %>").val();
#2
0
Do this, it works for me.the trick is to save your hidden field precious id in another hidden input field then build it back using that hidden value.
这样做,它适用于我。诀窍是将您隐藏的字段珍贵id保存在另一个隐藏的输入字段中,然后使用该隐藏值重新构建它。
Markup
标记
<asp:HiddenField ID="HiddenFieldMaster" runat="server" />
<input type="hidden" id="inputHidden" value='<%= HiddenFieldMaster.ClientID%>' />
Javascript
使用Javascript
$(function() {
$(".primaryStaticMenu tr,td").each(function(index) {
$(this).click(function() {
if ($(this).attr("title") != "undefined"
&& $(this).attr("title").length > 0) {
var inputHidden = document.getElementById('inputHidden');
$("#" + inputHidden.value).val($(this).attr("title"));
alert(inputHidden.value);
//return false;
}
});
});
});
Code Behind
代码背后
String Get_cng_value = HiddenFieldMaster.Value;