<%@ Page Title="About" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeFile="About.aspx.cs" Inherits="About" %>
<asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent">
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
var directionsDisplay;
var directionsService = new google.maps.DirectionsService();
function getParameterByName(name) {
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regexS = "[\\?&]" + name + "=([^&#]*)";
var regex = new RegExp(regexS);
var results = regex.exec(window.location.search);
if (results == null)
return "";
else
return decodeURIComponent(results[1].replace(/\+/g, " "));
}
function calcRoute() {
start = document.getElementById('startvalue').value;
end = document.getElementById('endvalue').value;
var request = {
origin: start,
destination: end,
travelMode: google.maps.DirectionsTravelMode.DRIVING
};
directionsService.route(request, function (response, status) {
if (status == google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(response);
this.distance = response.routes[0].legs[0].distance.value / 1000;
}
});
}
function Button1_onclick() {
calcRoute();
}
window.onload = InitializeMap;
</script>
<div style="height: 86px; width: 689px; margin-left: 16px; margin-top: 0px">
<table style="width: 96%;">
<tr>
<td class="auto-style1">
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</td>
<td>
<asp:TextBox runat="server" id ="startvalue"></asp:TextBox>
</td>
<td> </td>
</tr>
<tr>
<td class="auto-style2">
<asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
</td>
<td class="auto-style3">
<asp:TextBox runat="server" id ="endvalue"></asp:TextBox>
</td>
<td class="auto-style3"></td>
</tr>
<tr>
<td class="auto-style1"> </td>
<td>
<input id="Button1" type="button" value="GetDirections" onclick="return Button1_onclick()" />
</tr>
</table>
我想调用 Button1_onclick() 函数,但它不起作用。这段代码没有问题。问题是调用函数是错误的。所以拜托,你能告诉我我该怎么做吗..