所以我想创建一个可重复使用的视图来编辑地址,电话号码等.
我设置了一个容器模型,其中包含所需的所有模型.创建了一个局部视图来处理表单的Address部分
但是当它回发到控制器时,客户数据来自主页面,但部分视图中的任何内容都不存在(使用MVC4/Razor)
容器模型
public class CustomerViewModel {
public Customer CustomerData { get; set; }
public Address MainAddress { get; set; }
public Address ShippingAddress { get; set; }
public Phone MainPhone { get; set; }
public Phone Fax { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
控制器:
public ActionResult Edit(int id = 0) {
CustomerViewModel model = new CustomerViewModel();
model.CustomerData = Customer.FetchById(id);
if (model.CustomerData == null) return HttpNotFound();
//... load addresses, phones
return View(model);
}
[HttpPost]
public ActionResult Edit(CustomerViewModel model) {
if …Run Code Online (Sandbox Code Playgroud) 我一直试图解决这个问题,但没有成功 - 现在有这个作为占位符有效,但它很难...
.customField:nth-child(4),
.customField:nth-child(7),
.customField:nth-child(10),
.customField:nth-child(13),
.customField:nth-child(16) {
clear: both;
}
Run Code Online (Sandbox Code Playgroud)
我如何得到这个nth-child陈述?