当智能感知弹出时,我正在使用以下模型为我的一个视图构建一个 Html 助手,我不知道你能做到。基本上我的模型如下
public class Mainclass
{
public List<main> mainset { get; set; }
// do sth to load and save model info
}
public class main
{
public personalinfo info { get; set; }
public addressinfo currentaddr { get; set; }
public addressinfo[] otheraddr { get; set; }
public telephone currenttel { get; set; }
public telephone[] othertel { get; set; }
}
public class personalinfo
{
public string Name { get; set; }
public string Surname { get; set; }
public string Ni { get; set; }
public string dob { get; set; }
public employer currentemployer { get; set; } //another class employer
public employer[] otheremployer { get; set; } //an array of employer class
}
智能感知弹出的是(模型=> m.info.Name)。
@if ( Model.mainset != null){
foreach ( var m in Model.subset )
{
<div class="editor-label">
@Html.LabelFor(model => m.info.Name)
</div>
<div class="editor-field">
@Html.EditorFor(model => m.info.Name)
@Html.ValidationMessageFor(model => m.info.Name)
<div class="editor-label">
}
所以我想知道这个语句是如何工作的?是否可以让我直接在主模型中设置子字段而无需助手或 ajax 或 json?