发布到控制器时,视图模型对象属性未绑定

时间:2018-08-21 20:17:36

标签: .net asp.net-mvc model-view

这使我的头好几个小时了。如果我使用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();
}

0 个答案:

没有答案
相关问题