如何生成Html。处理复合对象的编辑器

时间:2022-09-26 21:03:27

I am faced with a style difficulty, I am currently building a site with the asp mvc framework. I am a big fan of the html.EditorFor option in the templates that generates a realy nice form for me. Because I really hate programming all the input fields myself. However I does not work as well with composite classes. If I have a class like:

我面临着风格上的困难,我目前正在用asp mvc框架构建一个站点。我非常喜欢html。在模板中为我生成一个非常好的表单的EditorFor选项。因为我讨厌自己编程所有的输入字段。但是,我在使用复合类时做得不太好。如果我有这样的课:

public class person{
  public Address address { get; set; }
  public Name    name   { get; set; }
}

public class Address{
  public string street { get; set; }
  public string zipcode { get; set; }
  ....
}
public class Name{
  ....
}

I would like the EditorFor function to generate a nice registration form asking for the name and address data however I seem to need to make a editortemplate for every class then. Which is nasty if i ever decide to change the class.

我想让EditorFor函数生成一个漂亮的注册表单来请求名称和地址数据,但是我似乎需要为每个类创建一个编辑模板。如果我决定改班,那就太糟糕了。

There for I am asking you. Is there a nice way to make this work? What setting do I need to make EditorFor generate the proper form without needing to make a template for every form myself?

因为我在问你。有什么好办法可以让它工作吗?我需要什么设置使EditorFor生成适当的表单而不需要自己为每个表单创建模板?

Again I don't mind it to much that i need to create those forms I would just rather have the system do that kind of stuff for me so that I can easily manipulate classes

我并不介意我需要创建这些表单我宁愿让系统为我做这些事情这样我就可以很容易地操作类

1 个解决方案

#1


1  

See Brad Wilson blog on 'deep diving' templates:

参见Brad Wilson关于“深度潜水”模板的博客:

http://bradwilson.typepad.com/blog/2009/10/aspnet-mvc-2-templates-part-3-default-templates.html

http://bradwilson.typepad.com/blog/2009/10/aspnet-mvc-2-templates-part-3-default-templates.html

#1


1  

See Brad Wilson blog on 'deep diving' templates:

参见Brad Wilson关于“深度潜水”模板的博客:

http://bradwilson.typepad.com/blog/2009/10/aspnet-mvc-2-templates-part-3-default-templates.html

http://bradwilson.typepad.com/blog/2009/10/aspnet-mvc-2-templates-part-3-default-templates.html