---
title: "How can I call this method?"  
description: "How can I call this method?"  
author: "Anonymous User"  
published: 2014-08-29  
updated: 2014-09-01  
canonical: https://www.mindstick.com/forum/2204/how-can-i-call-this-method  
category: "c#"  
tags: ["c#", ".net", "call methods", "calling methods", "function call in c#"]  
reading_time: 2 minutes  

---

# How can I call this method?

<%@ Page Title="About" [Language](https://www.mindstick.com/startup/28/preply-the-fast-growing-platform-transforming-language-learning)="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeFile="About.aspx.cs" Inherits="About" %>

<asp:[Content](https://www.mindstick.com/articles/13019/get-the-best-content-marketing-pricing-packages-for-your-brand) runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent">

<script type="text/[javascript](https://www.mindstick.com/articles/874/how-to-create-watermark-text-for-textbox-by-using-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](https://www.mindstick.com/articles/13001/multi-statement-table-valued-user-defined-function-in-sql-server) getParameterByName(name) {

name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");

var regexS = "[\\?&]" + name + "=([^&#]*)";

var regex = new RegExp(regexS);

var [results](https://yourviews.mindstick.com/story/4497/usage-of-baking-soda-magical-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](https://www.mindstick.com/blog/255/post-get-and-request-function-in-php) = {

origin: start,

[destination](https://yourviews.mindstick.com/story/1451/gorgeous-locations-for-destination-weddings-in-india): end,

travelMode: google.maps.DirectionsTravelMode.DRIVING

};

directionsService.route(request, function ([response](https://www.mindstick.com/forum/12719/how-to-make-response-write-display-special-character-like-lt-gt), 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](https://www.mindstick.com/forum/12714/dynamic-textbox-in-gridview) runat="server" id ="startvalue"></asp:TextBox>

</td>

<td>&nbsp;</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">&nbsp;</td>

<td>

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

</tr>

</table>

I want to call Button1_onclick() function but it doesn't work. This code has no [problem](https://yourviews.mindstick.com/view/81399/tackling-the-problem-of-unemployment-during-corona-pandemic). The problem is calling function is wrong. So please, could you tell me how can I do it.

## Replies

### Reply by Sumit Kesarwani

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() {           
alert('foo');        }    </script><input type="button" id="Button1" onclick="Button1_Click()" value="GetDirections" />
```


---

Original Source: https://www.mindstick.com/forum/2204/how-can-i-call-this-method

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
