I am just getting to grips with using ArcGIS Server 9.3.1. I am developing in .NET with a very basic Web app in C# - it has the standard ESRI web ADF ASP controls in the web page (Default.aspx) including a map and toolbar with some out of the box nav buttons. I have also made some custom tools on the toolbar.

I am interested in working with the Web ADF Javascript libraries not the ArcGIS JavaScript API - a subtle but important difference I believe.

How would I go about doing the following (bearing in mind I want to be firing the JavaScript via the ClientAction property - custom)?

  1. I need some javascript to work out where on the Map control the user has clicked and get a hold of the xy coordinates.
  2. Send these coordinates to a web service (I already have a web service set up to accept coordinates and send XML back).
  3. Parse the XML from the web service and put in a table.

1 Answer 1


I can't help you with steps 2 and 3, but those are javascript / AJAX calls that you can deal with once you have figured out where the map was clicked.

To set up a client-side handler in the .NET ADF, first configure a Tool that will call some javascript when you click on it:

    JavaScriptFile="" Name="ClientTest" />

Then add the handler that tells the Map to get a Point from the map:

<script type="text/javascript">
    var map;
    var mapID = 'Map1';

    function clickHandler(inputGeometry) {
        alert ('You clicked ' + 
            inputGeometry.get_x() + ', ' + 

    function setupCustomTool(name) {
        map = $find(mapID);            
        if (name == 'ClientTest') {

This will give you a point in map units. If you want lat/long, and your map units aren't already lat/long, you will need to reproject them. Proj4JS is the simplest way to do that.

With your favorite javascript debugger you can set a breakpoint inside the clickHandler function to inspect the inputGeometry, which will tell you more about what it contains and the methods it exposes.

This code is adapted from the example provided by ESRI with ArcGIS Server:

C:\Program Files\ArcGIS\developerkit\samplesnet\server\Web_Applications\Common_CustomJavaScriptCSharp.zip

Not the answer you're looking for? Browse other questions tagged or ask your own question.