The best way to send data to JavaScript functions from a Microsoft SQL Server Database
I have a bunch of location data (longitude and latitude pairs) sitting in a Microsoft SQL Server DB.
I need to plot those points on a Map (OpenLayers+OSM), and the only way to draw on the map is to use JavaScript.
So far, I have no idea how to achieve this goal. The only thing I know is that I do not want to establish a database connection in JavaScript. In other words, I need to somehow use c# to pass the 开发者_运维知识库data from database to Javascript. Any suggestions? All help is appreciated!
Write a asp.net generic handler page that fetches the data from the database and outputs a json string.
Then with jQuery parse that output and plot.
You can make use of WebMethods and JQuery here.
Following blog post with an example should give you an idea how you can easily reach the server side code from client side :
http://tugberkugurlu.com/archive/asp-net-web-forms---calling-web-service-page-methods-using-jquery
精彩评论