1
我必須在MVC4中實現分頁而不回發。我已經用回發實現了分頁。在mvc4中沒有回傳的尋呼
public ActionResult Index(int? page)
{
var model = from r in db.Country
orderby r.Description ascending
select r;
int pageSize = 10;
int pageNumber = (page ?? 1);
return View(model.ToPagedList(pageNumber, pageSize));
}
和我已經使用在視圖
<div id="pagelist">
Page @(Model.PageCount < Model.PageNumber ? 0 : Model.PageNumber) of @Model.PageCount
@if (Model.HasPreviousPage)
{
@Ajax.ActionLink("<<", "Index", new { page = 1 },null)
@Html.Raw(" ");
@Ajax.ActionLink("< Prev", "Index", new { page = Model.PageNumber - 1 },null)
}
else
{
@:<<
@Html.Raw(" ");
@:< Prev
}
@if (Model.HasNextPage)
{
@Ajax.ActionLink("Next >", "Index", new { page = Model.PageNumber + 1 },null)
@Html.Raw(" ");
@Ajax.ActionLink(">>", "Index", new { page = Model.PageCount },null)
}
else
{
@:Next >
@Html.Raw(" ")
@:>>
}
此代碼實現尋呼下面的代碼。但每次點擊下一個鏈接時,頁面都會刷新。我希望分頁不刷新頁面。