0

I have gridview filter data. I have two column longitude and latitude. I want to populate that data on bing map. I already get the Bing map and it works fine but I want multiple longitudes and latitude data to populate on the map. What did I do?

  • 1
    _In general_, the way to get C# variable data available in JavaScript is either to inject it into the JavaScript when the page loads, or fetch it separately via AJAX. You also mention a GridView - this will turn into a HTML table in your page, so another possibility is that you could write some JavaScript to extract the data from the table, if it's present when your page is loaded. Without any further context or code example from you, it's impossible to give more specific advice. – ADyson Oct 01 '18 at 13:14

1 Answers1

0

You can get data in javascript from code behind by these methods -

  1. Create a hidden field make it runat="server" so that it can be accessed from code behind and set the value in it from there and then you can access these hidden field values in javascript by document.getElementById("HiddenFieldId").value

  2. Set the values in the cookies from the codebehind and access the values of cookies from javascript

  3. you can also inject Javascript code directly from code behind on the page load using ClientScipt.RegisterStartupScript or ScriptMananger.RegisterStartupScript

There are many other methods please tell me if any of these helped

Amit chauhan
  • 540
  • 9
  • 22