admin管理员组文章数量:1432589
I'm trying to set hidden field value in JS which I think works fine with this approach:
<asp:HiddenField ID="hfLatSW" runat="server" />
var latSW = bounds.getSouthWest().lat();
$('#<%=hfLatSW.ClientID %>').value = latSW;
I am trying to access the value on asp button click in code behind gives me null value. What might be happening in the postback and why am I not able to access the value set by JavaScript?
I'm trying to set hidden field value in JS which I think works fine with this approach:
<asp:HiddenField ID="hfLatSW" runat="server" />
var latSW = bounds.getSouthWest().lat();
$('#<%=hfLatSW.ClientID %>').value = latSW;
I am trying to access the value on asp button click in code behind gives me null value. What might be happening in the postback and why am I not able to access the value set by JavaScript?
Share Improve this question edited Nov 10, 2021 at 21:18 halfer 20.4k19 gold badges109 silver badges202 bronze badges asked Apr 6, 2014 at 18:51 LazialeLaziale 8,24548 gold badges155 silver badges271 bronze badges1 Answer
Reset to default 3.value
isn't a jQuery property. Use .val()
:
$('#<%=hfLatSW.ClientID %>').val(latSW);
Or without jQuery:
document.getElementById('<%=hfLatSW.ClientID %>').value = latSW;
本文标签: How to set aspnet hidden field in JavaScript and access the value in C code behindStack Overflow
版权声明:本文标题:How to set asp.net hidden field in JavaScript and access the value in C# code behind - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745601651a2665600.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论