使用新数据刷新部分弹出窗口

时间:2013-11-25 18:46:14

标签: jquery ajax asp.net-mvc-3

我有一个部分显示一个表并具有后端分页。分页看起来像:

@Ajax.ActionLink(">>", "EventHistory", "Event", new { id = ViewBag.EventId, page = ViewBag.Page+1 }, new AjaxOptions { HttpMethod = "GET" })

调用:

public ActionResult EventHistory(int id, int page = 1)
    {
        var viewModel = eventService.GetHistory(id, page);
        ViewBag.EventId = id;
        ViewBag.Page = page;
        return PartialView("History", viewModel);
    }

调试时我可以看到viewModel中有正确的数据,但部分弹出窗口不会随新数据一起更新。如何使用正确的数据刷新或更新部分。

1 个答案:

答案 0 :(得分:1)

您需要设置AjaxOptions properties

new AjaxOptions { 
   HttpMethod = "GET", 
   InsertionMode = "Replace", // the mode that specifies how to insert the response into the target DOM element.
   UpdateTargetId = "ContainerId", //sets the ID of the DOM element to update by using the response from the server
}