【发布时间】:2013-10-18 13:07:02
【问题描述】:
我有一个模型: Menu 是 menuComponent 的子类
菜单组件有两个属性:名称和描述都是字符串
我创建了一个编辑视图并尝试使用 editorForModel() 创建编辑字段。 但它不会为其创建任何编辑字段。
@using (Html.BeginForm())
{
@Html.EditorForModel();
<input type="submit" value="Save" />
@Html.ActionLink("Cancel and return to List", "Index")
}
我必须使用@HTML.EditorFor() 来创建编辑文件
@using (Html.BeginForm())
{
@Html.EditorFor(m => m.Name);
@Html.EditorFor(m => m.Description);
<input type="submit" value="Save" />
@Html.ActionLink("Cancel and return to List", "Index")
}
为什么会这样?
【问题讨论】:
标签: asp.net-mvc-4 editorformodel