Custom editor templates not being called

46 views Asked by At

I have an MVC application using a number EditorTemplates and targetting .NET Framework 4.6.1. I have one that I want to use to render an Enum as a set of radio buttons my users can choose from.

In my ViewModel, I have the following:

public enum ApplicationType { Register, Replace, Renew }

[UIHint("EnumRadioButtons")]
public ApplicationType AppType { get; set; }

On my view, I'm using

@Html.EditorForModel(Model)

And my editor template looks something like:

@model Enum

var listItems = Enum.GetValues(Model.GetType()).OfType<Enum>().Select( e => 
  new SelectListIten()
  {
    Text = getDescription(e), //Function just used to get the Display Value
    Value = e.ToString(),
    Selected = e.Equals(Model)
  });
foreach (var li in listItems)
{
  //Render the Radio Button
}

I also have another Enum editortemplate which renders my Enums into a dropdown list. When rendering the EditorModel for my Model, the standard Enum editor template is used rather than my custom EnumRadioButtons template. Any ideas?

I've also used the [DataType("EnumRadioButtons")] decoration to no avail.

This worked before when I've used this exact method and specific editor templates but targeting 4.0 of the .NET Framework.

Thanks

Simon

0

There are 0 answers