Click here to Skip to main content
Click here to Skip to main content
 
Add your own
alternative version

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-v2-noexe.zip
MvcLocalizationEnumHelpers
MvcEnumDropDownList
App_Data
bin
bin
it-IT
it-IT
pt-PT
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
obj
Debug
it-IT
pt-PT
TempPE
Properties
Resources
Scripts
Views
Account
Home
Shared
packages
jQuery.1.5.1
Content
Scripts
jQuery.1.5.1.nupkg
MvcLocalizationEnumHelpers-v2.zip
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
mvclocalizationenumhelpers.zip
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
DesignTimeResolveAssemblyReferencesInput.cache
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;

using MvcEnumDropDownList.Resources;
using MvcEnumDropDownList.Helpers;

namespace MvcEnumDropDownList.Models
{
	[LocalizationEnum(typeof(MyResources))]
	public enum WeekDay
	{
		Sunday,
		Monday,
		Tuesday,
		Wednesday,
		Thursday,
		Friday,
		Saturday
	}


	#region without [LocalizationEnum]

	//public enum WeekDay
	//{
	//    Sunday,
	//    Monday,
	//    Tuesday,
	//    Wednesday,
	//    Thursday,
	//    Friday,
	//    Saturday
	//}

	#endregion

	#region No localization, using [Description] attribute

	//public enum WeekDay
	//{
	//    [Description("Domingo")]
	//    Sunday,

	//    [Description("Segunda")]
	//    Monday,

	//    [Description("Terça")]
	//    Tuesday,

	//    [Description("Quarta")]
	//    Wednesday,

	//    [Description("Quinta")]
	//    Thursday,

	//    [Description("Sexta")]
	//    Friday,

	//    [Description("Sábado")]
	//    Saturday
	//}

	#endregion
}

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) Dublin Entrprise & Technology Centre Limited
Ireland Ireland
My name is Rui Jarimba and I was born in Madeira island, Portugal and I currently live in Dublin, Ireland.
 
I’m working as a .NET software developer since 2005.
 
Some of my professional interests are:
 
Web development using .NET Framework;
Service Oriented Architecture (SOA);
Database development and modelling;
Web accessibility, usability, and standards;
Software Architecture;
Design Patterns
Follow on   Twitter   LinkedIn

| Advertise | Privacy | Mobile
Web02 | 2.8.140827.1 | Last Updated 6 Nov 2012
Article Copyright 2012 by Rui Jarimba
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid