Click here to Skip to main content
15,881,803 members
Articles / Web Development / ASP.NET
Article

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

Rate me:
Please Sign up or sign in to vote.
4.07/5 (7 votes)
6 Mar 2006CPOL2 min read 53.8K   748   26   2
Latitude longitude input control - as ASP.NET 2.0 server control.

Introduction

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.

Background

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.

Conclusions

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.

License

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


Written By
Software Developer (Senior)
Canada Canada
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralFirefox compatability Pin
redaccess25-Mar-09 10:00
redaccess25-Mar-09 10:00 
GeneralRe: Firefox compatability Pin
Gary Dryden25-Mar-09 11:54
Gary Dryden25-Mar-09 11: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.