Click here to Skip to main content
13,251,998 members (57,323 online)
Click here to Skip to main content
Add your own
alternative version


26 bookmarked
Posted 6 Mar 2006

Latitude/longitude input control: an ASP.NET 2.0 server control

, 6 Mar 2006
Rate this:
Please Sign up or sign in to vote.
Latitude longitude input control - as ASP.NET 2.0 server control.


This code drop is part of a smash and grab series. If you're in a rush, you can just grab this code and insert it into your application, no understanding is required. When you have some time (ya, right), you may want to review the source code.


I recently needed to enter latitude and longitude information into a GridView control, and so I wrote this ASP.NET 2.0 server control. The top part of the graphic shows the various input formats which you can toggle between using the spinners to the right. The bottom part shows the control in use in a FormView.

Using the code

  • Download the project, unzip it to somewhere on your hard disk.
  • Create a new ASP.NET project.
  • Create a Bin folder for the project.
  • Select Tools > Choose toolbox items.
  • Navigate to the unzip folder and select the DLL.
  • This new server control now appears in the toolbox (usually) under General.
  • Drag an instance of it onto Default.aspx.
  • Enjoy.

The control supports these properties:

  • LatitudeLongitude: Choose whether the control is to contain a latitude or a longitude value.
  • InputFormat: There are three common formats for latitude/longitude: Degrees (with a fractional degree part), Degrees and Minutes (with a fractional minute part), and Degrees, Minutes and Seconds. Use this property to set the default display format. At run time, you can choose a different format using the spin control.
  • ReadOnly: Set when you don't want to allow editing.

    You will set ReadOnly to true in the "ItemTemplate" of the GridView template for this control. You will set ReadOnly to false in the "EditItemTemplate" of the GridView template for this control.

Points of Interest

You must bind the Text property of the control to a floating point database type. You will also notice that there is no JavaScript or images that you need to add to your project. These are all imbedded in the DLL using WebResources. I have written an article on using WebResources, here at CodeProject. Search using the keywords redux WebResourse.


There you go, a free ASP.NET 2.0 Latitude/Longitude control that suits my needs and hopefully yours.

SmashGrab / Redux series

I have recently started two series of articles here at CodeProject. Smash&Grab is intended as a series of short articles on one specific code technique. Redux is intended as a series of longer articles which attempt to reduce a complicated topic (like GridView) into its basic constituent parts and show that once you have all the information, it wasn't really that hard after all. To find the Smash&Grab articles, search for the keyword SmashGrab. To find the Redux articles, search for keyword Redux. I welcome any contributions to either series, but please follow the guidelines when submitting articles to either.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Gary Dryden
Software Developer (Senior)
Canada Canada
No Biography provided

You may also be interested in...


Comments and Discussions

GeneralFirefox compatability Pin
redaccess25-Mar-09 11:00
memberredaccess25-Mar-09 11:00 
GeneralRe: Firefox compatability Pin
Gary Dryden25-Mar-09 12:54
memberGary Dryden25-Mar-09 12:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.171114.1 | Last Updated 6 Mar 2006
Article Copyright 2006 by Gary Dryden
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid