37S*_*ars 9 asp.net-mvc modelbinder
以下面的示例类为例.我想在表单上显示客户和两个地址(来自LIST).MVC beta中的模型绑定器是支持这个还是我必须编写自己的自定义绑定器?
public class Customer
{
public string FirstName { get; set; }
public string LastName { get; set; }
public List<Address> Addresses { get; set; }
public Customer()
{
Addresses = new List<Address>();
}
}
public class Address
{
public int Line1 { get; set; }
public int Line2 { get; set; }
public int City { get; set; }
public int State { get; set; }
public int Zip { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
你会如何编码字段?像这样?
<!-- some HTML formatting -->
<%= Html.TextBox("customer.address.line1", ViewData.Customer.Address[0].Line1)%>
<!-- some more HTML formatting -->
<%= Html.TextBox("customer.address.line1", ViewData.Customer.Address[1].Line1)%>
<!-- end of HTML form formatting -->
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3304 次 |
| 最近记录: |