asp.net + Accessing HiddenField value assigned in JS on Postback from CodeBehind
<p>I am trying to access my hiddenfield values from code behind but I got empty values instead, what I am doing here is setting the 2 hiddenfield values from a Javascript function and after that do a postback via asp:button click. Not sure what am I doing wrong here, please kindly assist:       </p>

<p>Thanks.</p>

<pre><code> &lt;form id="Form1" class="form" runat="server"&gt;

            &lt;p class="SearchAddress"&gt;
                &lt;asp:TextBox ID="searchTextField" runat="server" /&gt;
                &lt;label for="searchTextField"&gt;
                    Location&lt;/label&gt;
            &lt;/p&gt;
            &lt;p class="Date"&gt;
                &lt;asp:TextBox ID="txtDate" runat="server"&gt;18/10/2012&lt;/asp:TextBox&gt;
                &lt;label for="txtDate"&gt;
                    Date&lt;/label&gt;
            &lt;/p&gt;
            &lt;p class="TimeFrom"&gt;
                &lt;asp:TextBox ID="TimeFrom" runat="server"&gt;18:00&lt;/asp:TextBox&gt;
                &lt;label for="txtTimeFrom"&gt;
                    Time From&lt;/label&gt;
            &lt;/p&gt;
            &lt;p class="TimeTo"&gt;
                &lt;asp:TextBox ID="TimeTo" runat="server"&gt;19:00&lt;/asp:TextBox&gt;
                &lt;label for="txtTimeTo"&gt;
                    Time To&lt;/label&gt;
            &lt;/p&gt;

            &lt;p class="submit"&gt;
                &lt;asp:Button ID="btnCalculateCoordinates" runat="server" Text="Post It!" 
                  onClientclick="calculateCoordinates();" onclick="btnCalculateCoordinates_Click" 
            /&gt;
           &lt;/p&gt;

            &lt;asp:ScriptManager ID="ScriptManager1" runat="server" /&gt;
            &lt;asp:UpdatePanel ID="uppnlLatLong" runat="server" UpdateMode="Conditional"&gt;
            &lt;ContentTemplate&gt;
                         &lt;asp:HiddenField ID="txtLatitude" runat="server"  /&gt;
                         &lt;asp:HiddenField ID="txtLongitude" runat="server" /&gt;
             &lt;/ContentTemplate&gt;
           &lt;/asp:UpdatePanel&gt;
            &lt;/form&gt;

      function calculateCoordinates() {
                    var txtAddress1 = document.getElementById('&lt;%=searchTextField.ClientID%&gt;');
                    var txtLat = document.getElementById('&lt;%=txtLatitude.ClientID%&gt;');
                    var txtLng = document.getElementById('&lt;%=txtLongitude.ClientID%&gt;');

                    var address = txtAddress1.value + ', ';

                    var geocoder;
                    geocoder = new google.maps.Geocoder();

                    geocoder.geocode({ address: address }, function (results, status) {
                        if (status == google.maps.GeocoderStatus.OK) {
                            var location = results[0].geometry.location;
                            txtLat.value = location.lat(); //SETTING THE HIDDENFIELD VALUE
                            txtLng.value = location.lng(); //SETTING THE HIDDENFIELD  VALUE
                        }
                        else
                            alert('Opps, sorry but we are unable to locate' + $(txtAddress1).val());
                    });
            }
        &lt;/script&gt;
</code></pre>
