【发布时间】:2011-09-14 05:28:15
【问题描述】:
当我尝试发布数据并从具有局部视图的视图中调用操作时,我没有获得局部视图的模型数据,但是当我直接使用它而不是局部视图时,它会正确发送数据。
<div id="mydiv">
@using (Ajax.BeginForm("Index1", "Home", new AjaxOptions { UpdateTargetId = "mydiv", InsertionMode = InsertionMode.Replace, HttpMethod = "Post" }))
{
//Does not send data to action on post
@Html.Partial("ViewUserControl1",Model.Emps)
//ViewUserControl1 contains the same next 8 line logic.
OR
//Send the data to actions on post.
for (int i = 0; i < Model.Emps.Count(); i++)
{
@Html.TextBoxFor(x => x.Emps[i].Name)
@Html.TextBoxFor(x => x.Emps[i].Address)
@Html.ValidationMessageFor(x => x.Emps[i].BBString)
<br />
}
<input id="dosomething" type="submit" value="save" />
}
</div>
///On Controller
[HttpPost]
public ActionResult Index1(MyModel model)
{
///Here i am looking for the model data which is null for partial.
return View(model);
}
MyModel 有一个 Emps 列表 { Name,Address}
有谁知道这是什么原因。
【问题讨论】:
-
在此处发布您的
Index1操作。 -
ViewUserControl1部分包含什么? -
ViewUserControl1 包含相同的下 8 行。
标签: asp.net-mvc razor