这使我的头好几个小时了。如果我使用POCO,则不绑定,如果我不喜欢我的出租车,它将绑定回控制器。
This is my view model
public class testVM
{
public string selectedid {get;set;}
public string taxid {get;set;}
}
这是我的观点
@using VMNameSpace
@model testVM
/*tried this one too
@using (Html.BeginForm("myAction", "", FormMethod.Post,new {model = Model }))
*/
@using (Html.BeginForm("myAction", "", FormMethod.Post))
{
@Html.TextBoxFor(model => model.selectedid) <-- does not bind
//tried this one too
@Html.TextBoxFor(m => m.selectedid) <-- does not bind
@html.TextBox("model.taxid") <-- this binds
}
这是控制器
[HttpPost]
public ActionResult myAction(testVM model)
{
return View();
}