Reputation: 8225
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.net 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?
Upvotes: 0
Views: 7951
Reputation: 27012
.value
isn't a jQuery property. Use .val()
:
$('#<%=hfLatSW.ClientID %>').val(latSW);
Or without jQuery:
document.getElementById('<%=hfLatSW.ClientID %>').value = latSW;
Upvotes: 3