Home Search Contact us About us
Title A simple WebForm example using UTM and Lat/Long.
Summary This sample converts Latitude and Longitude values into UTM Northings and Eastings. In the process it demonstrates the use of a Simple WebForm events firing back to the server.
Contributor Chuck Gantz and John McTainsh
Published 5-Apr-2001
Last updated 1-Jan-2004
Page rating   84% for 14 votes Useless Brilliant
 Download Sample project files - 10 Kb


Here is a simple example of a WebForm that converts Lat-Long values to UTM and vice versa. The conversion routines were converted from C++ kindly provided by Chuck Gantz. The WebForm simply provides an easy way to wrap these routines. To see the project in action go to http://www.mctainsh.com/LatLongUtm.

Building the Project.

In this sample was built using Visual Studio.NET 7.0. Here we will cover building and running the WebForm.

  • First create a folder under wwwroot with the name LatLongUtm.
  • Ensure security is set to enable web sharing.
  • Using "Internet Service Manager". Right click on the LatLongUtm folder and Create an application name of the same.
  • Using Notepad edit the LatLongUtm.csproj.webinfo file and change Devlaptop01 to the name of you machine.
  • Start Visual Studio.NET and choose "File->Open Solution".
  • Open LatLongUtm.csproj.
  • Try to build the project. An error will occur.
  • Accept the error and save the LatLongUtm.sln file to c:\Inetpub\wwwroot\LatLongUtm.
  • Right click on LLUtmForm.aspx in the VS Solution Explorer and "Set As Start Page".
  • Select "Debug->Start without debugging" and the page should appear?

Getting Debugging Working.

Once we are this far we can track the process by setting break points and stepping through them. To do this we must enable debugging.

  • Right click on the Project in "VS Solution Explorer" and choose "Properties".
  • Choose "Configuration Properties \ Debug".
  • Set "Enable ASP.NET debugging" to True.
  • Insert a breakpoint and choose "Debug->Start" to run to it.

Some interesting points.

The "To UTM" and "To Lat-Long" radio buttons fire back to the server to disable the edit boxes. This is done by setting the "AutoPostBack" to true and creating a handler for it to call Enable and set the edit's background colour.

The Ellipsoid class is defined in the same namespace.

The Double.Format command is used to format the output with an embedded thousands separator.

Values are passed back in function parameters by reference using the out key word.

The Latitude and Longitude values are entered in decimal format.


Special thanks to Chuck Gantz for allowing me to use his excellent conversion routines. The majority of the code behind this example was provided by Chuck and any bugs were probably added by me.

Comments Date
dfd 23-Apr-2008 cd
Home Search Contact us About us