title: How to pass data from Code Behind to JavaScript?
body: <p>Hi I am having trouble to pass a value from a code behind (onLoad) to javascript.
  I am able to get the value for the address of the draggable marker(if INITIAL LAT and LONG value declared statically on javascript). Now I tried to load the value on ON Load value on Code behind using two hidden fields the problem is doesn't show the map and marker. Here's my code</p>
  
  <pre><code>&lt;div class="panel-body"&gt;
  
                      &lt;script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?v=3.exp&amp;key=AIzaSyCPzl7Nmzd71jMSTi46X5tGxpLCuo2n1sy"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
  
  
          var markers = [
  
              {
  
                  "title": 'Target Location',
                  //"lat": '43.7328831',
                  //"lng": '-79.6784712',
                  "lat": document.getElementById&lt;%= HdLat.ClientID%&gt;.value,
                  "lng": document.getElementById&lt;%= HdLng.ClientID%&gt;.value,
                  "description": ''
              }
          ];
  
          window.onload = function () {
              var mapOptions = {
                  center: new google.maps.LatLng(markers[0].lat, markers[0].lng),
                  zoom: 13,
                  mapTypeId: google.maps.MapTypeId.ROADMAP
              };
              var infoWindow = new google.maps.InfoWindow();
              var latlngbounds = new google.maps.LatLngBounds();
              var geocoder = geocoder = new google.maps.Geocoder();
              var map = new google.maps.Map(document.getElementById("dvMap"), mapOptions);
              for (var i = 0; i &lt; markers.length; i++) {
                  var data = markers[i]
                  var myLatlng = new google.maps.LatLng(data.lat, data.lng);
                  var marker = new google.maps.Marker({
                      position: myLatlng,
                      map: map,
                      title: data.title,
                      draggable: true,
                      animation: google.maps.Animation.DROP
                  });
                  (function (marker, data) {
                      google.maps.event.addListener(marker, "click", function (e) {
                          infoWindow.setContent(data.description);
                          infoWindow.open(map, marker);
                      });
                      google.maps.event.addListener(marker, "dragend", function (e) {
                          var lat, lng, address;
                          geocoder.geocode({ 'latLng': marker.getPosition() }, function (results, status) {
                              if (status == google.maps.GeocoderStatus.OK) {
                                  lat = marker.getPosition().lat();
                                  lng = marker.getPosition().lng();
                                  address = results[0].formatted_address;
                                  document.getElementById("mytext").value = address;
  
                              }
                          });
                      });
                  })(marker, data);
                  latlngbounds.extend(marker.position);
              }
              var bounds = new google.maps.LatLngBounds();
              map.setCenter(latlngbounds.getCenter());
              //map.fitBounds(latlngbounds);
          }
  
  
  &lt;/script&gt;
  &lt;div id="dvMap" style="width: 500px; height: 500px"&gt;
  &lt;/div&gt;
                     &lt;br /&gt;
  
  
  
                      &lt;div class="form-group"&gt;&lt;asp:Label ID="Label1" runat="server"&gt;&lt;/asp:Label&gt;&lt;br /&gt;
                          &lt;input type="text" id="mytext"  class="form-control" name="Address"/&gt;
  
               &lt;asp:Button ID="Button1" runat="server" Text="Button" /&gt;
                          &lt;%--&lt;asp:ImageButton ID="ImageButton4" runat="server" class="popovers" AlternateText="Point Location" Height="28px" ImageAlign="AbsMiddle" ImageUrl="~/img/maploc.png" Width="28px" data-original-title="Locate" data-content="Locate by means of map " data-placement="right" data-trigger="hover" /&gt;--%&gt;
                          &lt;asp:HiddenField ID="HdLat" runat="server" /&gt;
                           &lt;asp:HiddenField ID="HdLng" runat="server" /&gt;
                      &lt;/div&gt;
  </code></pre>
  
  <hr>
  
  <p>Code behind is</p>
  
  <pre><code> Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
          HdLat.Value = "43.7328831"
          HdLng.Value = "-79.6784712"
      End Sub
  </code></pre>
  
  <p>Hoping for your kind Help...</p>