开发者

Getting EditoFor to generate Editors for each property in a model

I have a custom class and I'm trying to use EditorFor to display the editor for each of the properties of the class (blarg, blah, bar.) It will generate the editors for blarg and blah开发者_运维百科 but not bar. I have an Editor Template for Foo and it works fine if I use EditorFor( m => m.bar). At first I assumed it just wouldn't use an Editor Template that I had defined but when I defined an Editor Template for DateTime, blah used it instead of the default template.

Is there any way to have the editor for Foo be generated (from an editor template) automatically when calling EditorFor(CustomClass)?

public class CustomClass
{
    public string blarg { get; set; }
    public DateTime blah { get; set; }
    public Foo bar { get; set; }
}

public class Foo()
{
    public string fooBar {get; set;}
}


You could write a custom editor template for the object class which will scaffold your complex model properties.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜