2013-11-25 162 views
0

我有一個局部顯示一個表,並有後端分頁。分頁的樣子:刷新本頁面有新數據

@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); 
    } 

調試時,我可以看到視圖模型中有正確的數據,但部分彈出窗口不會用新的數據更新。如何使用正確的數據刷新或更新部分。

回答

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 
}