[英]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. 我在Microsoft SQL Server数据库中有一堆位置数据(经度和纬度对)。
I need to plot those points on a Map (OpenLayers+OSM), and the only way to draw on the map is to use JavaScript. 我需要在地图(OpenLayers + OSM)上绘制这些点,并且在地图上绘制的唯一方法是使用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.
我唯一知道的是我不想在JavaScript中建立数据库连接。 In other words, I need to somehow use c# to pass the data from database to Javascript.
换句话说,我需要以某种方式使用c#将数据从数据库传递到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. 编写一个asp.net通用处理程序页面,该页面从数据库中获取数据并输出json字符串。
Then with jQuery parse that output and plot. 然后使用jQuery解析该输出并进行绘图。
You can make use of WebMethods and JQuery here. 您可以在此处使用WebMethods和JQuery。
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 http://tugberkugurlu.com/archive/asp-net-web-forms---calling-web-service-page-methods-using-jquery
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.