The [Display] attribute is a .NET 4-specific attribute. Since MVC 2 is compiled against .NET 3.5, the runtime does not recognize this attribute.
See http://aspnet.codeplex.com/WorkItem/View.aspx?WorkItemId=5515 for more information plus workarounds.
Edit:
Eh, the work item's not that big. May as well include it inline. :)
The [Display] attribute is new in
DataAnnotations v4, so MVC 2 can't use
it because we're compiled against
DataAnnotations v3.5. Use
[DisplayName] instead until MVC 3,
where we will be compiled against
DataAnnotations v4.
You have a few workarounds. When .NET
4 RTMs, we will provide a .NET
4-specific Futures binary, and that
Futures binary will have a metadata
provider that understands [Display]
and other DataAnnotations v4-specific
attributes. Alternatively, if you need
a solution right away, subclass the
[DisplayName] attribute, make a
private DisplayNameAttribute field
that's instantiated appropriately, and
override the virtual
DisplayNameAttribute.DisplayName
property so that it delegates to
_theWrappedDisplayNameAttribute.GetName().
public class MultiCulturalDisplayName : DisplayNameAttribute {
private DisplayAttribute display;
public MultiCulturalDisplayName(Type resourceType, string resourceName) {
this.display = new DisplayAttribute { ResourceType = resourceType, Name = resourceName };
}
public override string DisplayName {
get { return display.GetName(); }
}
}