Click here to Skip to main content
12,501,010 members (47,249 online)
Click here to Skip to main content

Stats

34.4K views
1.2K downloads
28 bookmarked
Posted

ASP.NET MVC: Creating localized DropDownLists for enums

, 6 Nov 2012 CPOL
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
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)
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

You may also be interested in...

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