I'm new to this whole asp thing so you'll have to forgive me if I sound a little confused and/or this question or something similar has already been answered.
I currently have a page(html) showing our office locations with a form on the sidebar that asks for your address, city state and zip, and a dropdown to select one of our offices.
After the user fills in the appropriate information, a javascript pulls the address fields together and puts the string into a hidden input field, and the form is submitted to maps.google.com/maps with the appropriate information ("saddr"-start address,
"daddr"-destination address) and viola! -up pops a google map with a nice line from them to us.
I'm trying to port this over to asp to eliminate the javascript to avoid problems for people who disable scripting. (like me) I've got asp text boxes and dropdowns on my form and I've written a sub to put the fields together. I've specified the correct
postbackurl in the submit button and an onclick event to run the sub.
Problems:
<div mce_keep="true">The sub doesn't run</div>
<div mce_keep="true">Google opens, but doesn't carry any of my information with it, so it's not opening the directions page</div>
Somehow, with fooling around last night, I got the page to open with the daddr, but I got so frustrated that I killed off what I was writing, and now, for the life of me, I have no idea what I did.
I've tried bypassing the sub, but I still get problem #2 (and I'd really like to make it work with the sub)
What am I doing wrong?? (besides working too late) Am I going about it all wrong? Can I programatically put in the postbackurl from my form "http://maps.google.com/maps?saddr=blah+blah&daddr=our+address?
Partial Class example_Default4
Inherits System.Web.UI.Page
Protected Sub GoToGoogle(ByVal o As Object, ByVal e As EventArgs) Handles do_address.Click
Dim fulladdress As String = String.Format("{0}+{1}+{2}+{3}+{4}", address1.Text, address2.Text, city.Text, state.Text, zip.Text) Dim gotoaddress As String = "1600+Amphitheatre+Parkway+Mountain View+CA+94043"
Response.Redirect(String.Format("http://maps.google.com/maps?saddr={0}&daddr={1}", fulladdress,gotoaddress))
End Sub
End Class
None
0 Points
2 Posts
Google driving directions?
Feb 17, 2009 05:48 PM|JC Warren|LINK
I'm new to this whole asp thing so you'll have to forgive me if I sound a little confused and/or this question or something similar has already been answered.
I currently have a page(html) showing our office locations with a form on the sidebar that asks for your address, city state and zip, and a dropdown to select one of our offices.
After the user fills in the appropriate information, a javascript pulls the address fields together and puts the string into a hidden input field, and the form is submitted to maps.google.com/maps with the appropriate information ("saddr"-start address, "daddr"-destination address) and viola! -up pops a google map with a nice line from them to us.
I'm trying to port this over to asp to eliminate the javascript to avoid problems for people who disable scripting. (like me) I've got asp text boxes and dropdowns on my form and I've written a sub to put the fields together. I've specified the correct postbackurl in the submit button and an onclick event to run the sub.
Problems:
Somehow, with fooling around last night, I got the page to open with the daddr, but I got so frustrated that I killed off what I was writing, and now, for the life of me, I have no idea what I did.
I've tried bypassing the sub, but I still get problem #2 (and I'd really like to make it work with the sub)
What am I doing wrong?? (besides working too late) Am I going about it all wrong? Can I programatically put in the postbackurl from my form "http://maps.google.com/maps?saddr=blah+blah&daddr=our+address?
Contributor
6434 Points
1435 Posts
Re: Google driving directions?
Feb 17, 2009 07:32 PM|nvanhaaster@resultstel.com|LINK
Try this out using response.redirect
Codebehind
My .Net Blog
My Links are shrunk by t-ny.co
None
0 Points
2 Posts
Re: Google driving directions?
Feb 18, 2009 09:34 AM|JC Warren|LINK
Thank you!! Nice, simple, elegant!!
I had the feeling I was using the wrong approach.
Contributor
6434 Points
1435 Posts
Re: Google driving directions?
Feb 19, 2009 06:28 AM|nvanhaaster@resultstel.com|LINK
Please mark as answer if the solution provided worked
My .Net Blog
My Links are shrunk by t-ny.co