如何为枚举创建默认编辑器模板?我的意思是:我可以做这样的事情:
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<Enum>" %> 
<% -- any code to read the enum and write a dropdown -->
并将其放在EditorTemplates文件夹下的名称下Enum.ascx?
这是我尝试过的问题的解决方法,但这不是我需要的.
这是我的枚举:
public enum GenderEnum
{
    /// <summary>
    /// Male
    /// </summary>
    [Description("Male Person")]
    Male,
    /// <summary>
    /// Female
    /// </summary>
    [Description("Female Person")]
    Female
}
我制作了一个名为的模板GenderEnum.acsx并将其放入Shared/EditorTemplates文件夹中.这是模板:
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<AlefTech.HumanResource.Core.GenderEnum>" %>
<%@ Import Namespace="AlefTech.HumanResource.WebModule.Classes" %>
<%=Html.DropDownListFor(m => m.GetType().Name, Model.GetType()) %>
当然这个方法是我自己的:
public static class HtmlHelperExtension
    {
        public static MvcHtmlString DropDownListFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, …