我有以下ViewData,我传入视图。部分与查看数据对象
public class MerchantSignUpViewData : BaseViewData
{
public Merchant Merchant { get; set; }
public Address Address { get; set; }
public Deal Deal { get; set; }
public List<MerchantContact> Contacts { get; set; }
public int TabIndex { get; set; }
public List<DealPricing> DealPricing { get; set; }
}
我还创建了3个部分视图。商家信息,地址,商家属性
在我看来,我有一个共享相同的字段名商人,这是“名”
我不能把这些相同的形式造成的名字将在交易模式是相同的。
我最终做的是将所有10个部分视图放到一个巨大的表单中(我开始在这个时候哭了)并且像这样绑定。
<%: Html.TextBoxFor(model => model.Deal.Name)%>
<%: Html.TextBoxFor(model => model.Deal.Name)%>
这给了我正确的表单元素名称。
我想要做的是以下几点。
<% Html.RenderPartial("MerchantForm", Model.Merchant) %>
<% Html.RenderPartial("DealForm", Model.Deal) %>
但是,如何为所有TextBoxFor件添加前缀,或者最好是渲染部分标记。
希望我提供了足够的信息,或者我只是做错了这一点。从长远来看,两者都会帮助我,所以在此先感谢。
看看http://stackoverflow.com/questions/955371/partial-view-with-parametrized-prefix-for-controls-names我想你是在问一个类似的问题。 – HitLikeAHammer 2010-10-05 23:57:35