Home > DeveloperSection > Forums > How can I call this method?
john rob

Total Post:108

Posted on    August-29-2014 1:17 AM


 1 Reply(s)
 1093  View(s)
Rate this:

<%@ 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 "";


            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) {


                this.distance = response.routes[0].legs[0].distance.value / 1000;




    function Button1_onclick() {



    window.onload = InitializeMap;


    <div style="height: 86px; width: 689px; margin-left: 16px; margin-top: 0px">

        <table style="width: 96%;">


                <td class="auto-style1">

                    <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>



                    <asp:TextBox  runat="server" id ="startvalue"></asp:TextBox>





                <td class="auto-style2">

                    <asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>


                <td class="auto-style3">

                    <asp:TextBox runat="server" id ="endvalue"></asp:TextBox>


                <td class="auto-style3"></td>



                <td class="auto-style1">&nbsp;</td>


                       <input id="Button1" type="button" value="GetDirections" onclick="return Button1_onclick()" />



I want to call Button1_onclick() function but it doesn't work. This code has no problem. The problem is calling function is wrong. So please, could you tell me how can I do it.

Sumit Kesarwani

Total Post:378

Posted on    September-01-2014 12:21 AM

Have you tried removing the return from the function call? This code fires the event.

<asp:Content ID="ContentMain" ContentPlaceHolderID="ContentBody" runat="server">   

    <script type="text/javascript" language="javascript">

        function Button1_Click() {




<input type="button" id="Button1" onclick="Button1_Click()" value="GetDirections" />

Don't want to miss updates? Please click the below button!

Follow MindStick