1

即使我添加了 @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);
    }

模型有效但始终为空

4

0 回答 0