我SomeModel的定义为:
public class SomeModel
{
public string property1 { get; set }
public bool property2 { get; set; }
}
我有一个动作:
public ActionResult Edit(int id)
{
SomeModel model = new SomeModel();
//... populate model ...
return View(model);
}
假设在视图中property1andproperty2被实例化为@Html.EditorFor,在这种情况下property1将呈现为 a<input type='text'>并且property2将是 a <input type='checkbox'>。
如果我有以下控制器操作来处理来自编辑表单的提交:
[HttpPost]
public ActionResult Edit(int id, SomeModel model, FormCollection collection)
{
}
如果有的话,如何填充参数模型?