當我嘗試發佈數據並從具有部分視圖的視圖調用操作時,我沒有獲得部分視圖的模型數據,但是當我直接使用它時而不是它正確發送數據的部分視圖。@ Ajax.BeginForm中的Html.Partial不會將數據發佈到操作
<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 {名稱,地址}
的有誰知道這樣做的原因。
在這裏發表您'Index1'行動。 –
'ViewUserControl1'部分包含什麼? –
ViewUserControl1包含接下來的8行。 –