|
| Recent
Articles |

See Who Calls Any Method In C# In some situations it can be important to know which methods are calling other methods. Think of an error log. Here you would like to know which method that threw the error and at what line in what file. This helps to debug...
Compress & Decompress Strings In C# A couple of days ago, I had to store some very big strings in an XML file. To keep the file size down I wanted to compress the strings using a GZipStream and then decompress them later when needed. I modified...
Nokia Eases The Pain For C And Linux Developers For mobile application developers and those creating LBS apps this is huge! Editor's Note: I have taken the liberty of posting a link to this story in the programming forum at WebProWorld. I'd like to encourage WPW...
Generate Unique Strings & Numbers In C# The System.Guid is used whenever we need to generate a unique key, but it is very long. That's in many cases not an issue, but in a web scenario where it is part of the URL we need to use its string representation which...
C# - Generic Plug-in Application At work, we are about to build a new internal tool for administration of different systems. We developers need certain applications and the sales department needs some other ones. All the different people need to be...
C# - Screen Scraping Some say that screen scraping is a lost art because it is no longer an advanced discipline. That may be right, but there are different ways of doing it. Here are some different ways that all are perfectly acceptable...
|
|
 |
|
05.29.07 Bind Countries From CultureInfo Class In C# By
Mads Kristensen Some people have asked me how BlogEngine.NET displays a dropdown list of countries when no source XML file is present.
The simple answer is that you don't need any external list to bind to from C#, you can instead use the CultureInfo class.
Consider that you have the following dropdown list declared in an ASP.NET page:
The method first adds all the countries from the CultureInfo class to a dictionary and then sorts it alphabetically. Last, it tries to retrieve the country of the browser so it can auto-select the visitors country. There might be a prettier way to sort a dictionary, but this one works.
Comments
About the Author: Mads Kristensen currently works as a Senior Developer at Traceworks located
in Copenhagen, Denmark. Mads graduated from Copenhagen Technical Academy with a multimedia degree in
2003, but has been a professional developer since 2000. His main focus is on ASP.NET but is responsible for Winforms, Windows- and
web services in his daily work as well. A true .NET developer with great passion for the simple solution.
http://www.madskristensen.dk/
|
|