代码之家  ›  专栏  ›  技术社区  ›  Zachary Scott

在MVC 2中,如何为UI帮助器模板(而不是属性)注释类?

  •  4
  • Zachary Scott  · 技术社区  · 15 年前

    我知道这适用于单房地产 Scott Guthrie's blog 要自动神奇地使用局部视图来呈现传递给它的局部模型(类似于动态数据中的UI助手):

    [UIHint("StateDropDown")]
    public string State { get; set;}
    

    但是如何注释整个类以使用这样的UI助手:

    [UIHint("Address")]
    public class Address {
        public string addr1 { get; set; } 
        public string addr2 { get; set; } 
        public string city { get; set; }
        [UIHint("StateDropDown")]
        public string state { get; set; } 
        public string zip { get; set; } 
    }
    

    (除了[uihint(“address”)]似乎不适用于类。我在他的示例中看到,他在shared->editorTemplates文件夹中有“customer.aspx”,因此我认为这是可能的。

    1 回复  |  直到 15 年前
        1
  •  3
  •   Brad Wilson    15 年前

    用类的名称创建一个模板,它就可以工作了。