I\'ve been using Editor-Templates in the past like this, by applying the following data annotation:
[UIHint("SomeTemplate")]
You could use the UHint without AdditionalMetadata attribute, but some additional code is requred
[UIHint("DateTime", null, "key1", "value1", "key2", "value2")]
public DateTime Date { get; set; }
override CreateMetadata:
public class CustomMetadataProvider : DataAnnotationsModelMetadataProvider
{
public const string UiHintControlParameters = "UiHintControlParameters";
protected override ModelMetadata CreateMetadata(
IEnumerable attributes,
Type containerType,
Func
Register CustomMetadataProvider:
public static void Application_Start()
{
ModelMetadataProviders.Current = new CustomMetadataProvider();
}
and in your template:
@{
IDictionary values = (IDictionary)
ViewData.ModelMetadata.AdditionalValues[CustomMetadataProvider.UiHintControlParameters];
}