Click here to Skip to main content
13,096,660 members (89,991 online)
Click here to Skip to main content

Stats

38.5K views
1.2K downloads
29 bookmarked
Posted 17 Feb 2012

ASP.NET MVC: Creating localized DropDownLists for enums

, 6 Nov 2012
A collection of HTML helpers that generate DropDownLists for enums, with or without localization support.
MvcLocalizationEnumHelpers
MvcEnumDropDownList
Content
images
lang-en.jpg
lang-it.jpg
lang-pt.jpg
themes
base
images
ui-bg_flat_0_aaaaaa_40x100.png
ui-bg_flat_75_ffffff_40x100.png
ui-bg_glass_55_fbf9ee_1x400.png
ui-bg_glass_65_ffffff_1x400.png
ui-bg_glass_75_dadada_1x400.png
ui-bg_glass_75_e6e6e6_1x400.png
ui-bg_glass_95_fef1ec_1x400.png
ui-bg_highlight-soft_75_cccccc_1x100.png
ui-icons_222222_256x240.png
ui-icons_2e83ff_256x240.png
ui-icons_454545_256x240.png
ui-icons_888888_256x240.png
ui-icons_cd0a0a_256x240.png
Controllers
Global.asax
Helpers
ClassDiagram1.cd
Models
MvcEnumDropDownList.csproj.user
Properties
Resources
Scripts
Views
Account
Home
Shared
packages
jQuery.1.5.1
Content
Scripts
jQuery.1.5.1.nupkg
bin
EntityFramework.dll
lang-en.jpg
lang-it.jpg
lang-pt.jpg
ui-bg_flat_0_aaaaaa_40x100.png
ui-bg_flat_75_ffffff_40x100.png
ui-bg_glass_55_fbf9ee_1x400.png
ui-bg_glass_65_ffffff_1x400.png
ui-bg_glass_75_dadada_1x400.png
ui-bg_glass_75_e6e6e6_1x400.png
ui-bg_glass_95_fef1ec_1x400.png
ui-bg_highlight-soft_75_cccccc_1x100.png
ui-icons_222222_256x240.png
ui-icons_2e83ff_256x240.png
ui-icons_454545_256x240.png
ui-icons_888888_256x240.png
ui-icons_cd0a0a_256x240.png
Global.asax
ClassDiagram1.cd
MvcEnumDropDownList.csproj.user
jQuery.1.5.1.nupkg
App_Data
bin
it-IT
EntityFramework.dll
it-IT
pt-PT
lang-en.jpg
lang-it.jpg
lang-pt.jpg
ui-bg_flat_0_aaaaaa_40x100.png
ui-bg_flat_75_ffffff_40x100.png
ui-bg_glass_55_fbf9ee_1x400.png
ui-bg_glass_65_ffffff_1x400.png
ui-bg_glass_75_dadada_1x400.png
ui-bg_glass_75_e6e6e6_1x400.png
ui-bg_glass_95_fef1ec_1x400.png
ui-bg_highlight-soft_75_cccccc_1x100.png
ui-icons_222222_256x240.png
ui-icons_2e83ff_256x240.png
ui-icons_454545_256x240.png
ui-icons_888888_256x240.png
ui-icons_cd0a0a_256x240.png
Global.asax
ClassDiagram1.cd
MvcEnumDropDownList.csproj.user
obj
Debug
DesignTimeResolveAssemblyReferencesInput.cache
it-IT
pt-PT
TempPE
Resources.Copy of MyResources.Designer.cs.dll
Resources.Copy of MyResources.pt-PT.Designer.cs.dll
Resources.MyOtherResources.Designer.cs.dll
Resources.MyOtherResources.it-IT.Designer.cs.dll
Resources.MyOtherResources.pt-PT.Designer.cs.dll
Resources.MyResources.Designer.cs.dll
Resources.MyResources.it-IT.Designer.cs.dll
Resources.MyResources.pt-PT.Designer.cs.dll
Views.Home.MyResources.Designer.cs.dll
MvcLocalizationEnumHelpers.sln.docstates.suo
MvcLocalizationEnumHelpers.suo
jQuery.1.5.1.nupkg
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8" />
	<title>@ViewBag.Title</title>
	<link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />
	<script src="@Url.Content("~/Scripts/jquery-1.5.1.min.js")" type="text/javascript"></script>
	<script src="@Url.Content("~/Scripts/modernizr-1.7.min.js")" type="text/javascript"></script>
</head>
<body>
	<div  id="nav">
		<ul id="navlist">  
			<li>
				<img src='@Url.Content("~/Content/images/lang-pt.jpg")' class='flag' alt='Português' /> 
				@Html.ActionLink("Português", "Language", "Home", new { language = "pt-PT" }, null )
			</li>
			<li>
				<img src='@Url.Content("~/Content/images/lang-en.jpg")' class='flag' alt='English' /> 
				@Html.ActionLink("English", "Language", "Home", new { language = "en" }, null )
			</li>
			<li>
				<img src='@Url.Content("~/Content/images/lang-it.jpg")' class='flag' alt='Português' /> 
				@Html.ActionLink("Italiano", "Language", "Home", new { language = "it-IT" }, null )
			</li>		
		</ul>		
	</div>

	@RenderBody()
</body>
</html>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

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

Share

About the Author

Rui Jarimba
Software Developer (Senior)
Italy Italy
My name is Rui Jarimba and I was born in Madeira island, Portugal and I currently live in Rome, Italy.

I have more than 10 years of experience developing software using the .NET Framework and other technologies (Web development, Databases, ...).

Some of my professional interests are: software development best practices, software architecture, cloud computing, Continuous Integration (CI), Continuous Delivery (CD) and agile methodologies such as Scrum, Kanban, Lean and any other methodology that can help me to become a better and more productive software engineer.

I believe in good code - code that is readable, maintainable, reusable, testable and deployable. This means that I'm not the "quick and dirty" type, I write code for the medium/long term whenever possible.

Something else about me - I love music, I am an amateur photographer, not a big fan of gyms (I prefer to do some outdoor activity such as walking/hiking), big foodie (I love Mediterranean cuisine and my glass of wine!).

You may also be interested in...

Pro
Pro
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.170813.1 | Last Updated 6 Nov 2012
Article Copyright 2012 by Rui Jarimba
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid