Hey Guys,

I am developing a website similar to google maps in visual studio 2008 using google maps api.
I am passing user input as source,destination and have provided three timestamps in form asp radiobutton list.

This is my javascrpit code:

 function calcRouteA() {

        var start = document.getElementById('DropDownList1').value;
        var end = document.getElementById('DropDownList2').value;
        var request = {
            origin: start,
            destination: end,
            provideRouteAlternatives: true,
            unitSystem: google.maps.UnitSystem.METRIC,
            travelMode: google.maps.DirectionsTravelMode.TRANSIT,
            transitOptions: {
            departureTime: new Date(1362568344000)

        directionsService.route(request, function (response, status) {
            if (status == google.maps.DirectionsStatus.OK) {


For some reasons i am not able to parse this function with asp:radiobutton and not able to integrate it with asp:button inturn.
Please reply asap.
Thanks in advance

Recommended Answers

All 6 Replies

Make sure you are using the correct ID for the asp: controls....the controls get new names once they are served from IIS. Look at the source code (View Source in IE) to get the new names that you will reference.

You want to go ahead and verify the IDs for your controls. asp.net will rename them so if you take a look at the source code via your browser, you'll see that its no longer called "DropDownList1", etc..

If you do not want the IDs to change, make them static... On the control, add this attribute...


So for example....

<asp:DropDownList ID="DropDownList1" runat="server" ClientIDMode="Static" />

The clientIDMode of static will ensure that the ID that you choose will be used client side. Of course, with statics, you have to ensure that the ID is unique on the page since asp.net is no longer assigning the client ID.

VERY COOL!! Thanks JorgeM I never knew that could be done!!

Also, if you are not running asp.net 4, here is another approach...

          var start = document.getElementById("<%=DropDownList1.ClientID%>").value;

That would be the way I would normally handle the IDs in javascript or jQuery. Or create a variable to hold the prefix of the ID in javascript and then concatenate it to the simple id when I want to reference it, that way it can be flexible if the need arises like multiple possible controls.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.