Sunday, May 19, 2024
Homepage · c#
 Popular · Latest · Hot · Upcoming
53
rated 0 times [  55] [ 2]  / answers: 1 / hits: 7489  / 10 Years ago, sun, april 6, 2014, 12:00:00

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?


More From » c#

 Answers
3

.value isn't a jQuery property. Use .val():



$('#<%=hfLatSW.ClientID %>').val(latSW);


Or without jQuery:



document.getElementById('<%=hfLatSW.ClientID %>').value = latSW;

[#46252] Friday, April 4, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
mikael

Total Points: 73
Total Questions: 115
Total Answers: 86

Location: Central African Republic
Member since Mon, Aug 10, 2020
4 Years ago
;