Hi Guys,
A quick and hopefully simple question.
If you map a google maps application and want to store every location the user clicks on, how can you store that data in vb.net/asp.net in a collection, with the intention of putting it in a database later.
I’m pretty sure I know how to store it in javascript, perhaps with an array, but I’m unsure of how to transfer that into the application (Without sticking it in visible text that the user sees or adding it to a form).
Any suggestions?
No, that is javascript, using jQuery. The “varThatCOntainsPoint” is the javascript var containing the point.
I also always use IHttpHandlers. googleMapHandler.ashx
Thank you for your code sample, I’m sure it will be very valuable.
This is my first time working with ajax.
Is that JSON that you’ve written?
Where you’ve written “varThatContainsPoint”, would that be the asp.net variable name that I intend to use, or would it be the variable name within the javascript file containing those points?
I will research HttpHandler and hopefully that will also help guide me.
^^^^What he said. On the server-side, look into a plain-jane IHttpHandler implementation to take the data. No need to complicate things with full-page lifecycle, etc.
I think I might be thinking about this in the wrong way.
What I’d like to do is take all points clicked on in a google maps app, and each time, add it to a collection that can then be handled, manipulated and stored in a database through vb.net/asp.net.
I have a feeling I’d have to add the data through javascript to a hidden div within the update panel, and upon each click (Somehow) get vb.net to pick up on the change, add it to a collection, clear the div then update the panel.
Can anyone clarify, or suggest a better method?
Like I said, use jQuery. Leave update panels and MS Ajax. If you can get the point and the click event in js, put something like this in the click event to post to asp.net page:
$.ajax({
url: 'ajax/googleMapHandler.aspx',
type: 'POST',
data: 'point=' + varThatContainsPoint + '&point2=' + varThatContainsPoint2,
success: function(msg) {
//Put code here after response is received from asp.net
}
});
I hope that helps a bit.
Good luck
thanks for the tip.
How would I go about doing an update post to the .net page?
I’ll be using jquery.
Does it involve using the update panel? And if so do you need to do something with the script manager within asp.net?
Well, if you can get the data with javascript, then you will also need to use javascript to do an ajax post to a .net page that saves the values. I would suggest using jQuery, as it makes doing ajax posts very easy