Click here to Skip to main content
Click here to Skip to main content

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.

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)

About the Author

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

Comments and Discussions

 
GeneralFirefox compatability Pinmemberredaccess25-Mar-09 10:00 
GeneralRe: Firefox compatability PinmemberGary Dryden25-Mar-09 11:54 

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

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

| Advertise | Privacy | Mobile
Web02 | 2.8.140721.1 | Last Updated 6 Mar 2006
Article Copyright 2006 by Gary Dryden
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid