Hi,
declare string variable. and make that function as string and assign that string value in that variable.
string jsFn = "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) { directionsDisplay.setDirections(response); }"
+ " });}";
call that function like below...
ddl1.Attributes.Add("onselect", jsFn);