MVC4 Postback Viewmodel是空的,即使有HiddenFor,任何想法?

时间:2013-07-26 15:26:39

标签: asp.net-mvc asp.net-ajax html-helper

即使我添加了@ Html.HiddenFor(model => model.SomeObject.ID)

回发后我的Viewmodel仍然为空。

这是我的一些Razor代码:

@model Application.ViewModels.AppViewModel

...

@using (Ajax.BeginForm(null, new AjaxOptions { HttpMethod = "POST" }, null))
{
<fieldset>
    <legend>Participants</legend>
    @Html.HiddenFor(model => model.SomeObject.ID)
     ... (Other Hidden items)

... (Displaying some stuff)

}

我的控制器代码:

    [HttpPost]
    public ActionResult Draw(AppViewModel model)
    {
        if (ModelState.IsValid)
        {
            if (model.SomeObject != null) model.RunDraw(model.SomeObject.ID);
        }
        return View(model);
    }

模型有效但始终为空

0 个答案:

没有答案