I'm using PagedList with Ajax, but I'm not getting a page change because when I click the button that represents the page, the value that is going to the controller is null. I made the following structure:
View:
@model PagedList.IPagedList<MeuProjeto.Web.ViewModels.ClienteViewModel>
@using PagedList.Mvc;
...
<div id="ClientesTableDiv">
@Html.Partial("_ClientesTable", Model)
</div>
@Html.PagedListPager(Model, pagina => Url.Action("Paginacao","Cliente", pagina ),
PagedListRenderOptions.EnableUnobtrusiveAjaxReplacing(
new AjaxOptions() {
HttpMethod = "POST",
UpdateTargetId = "ClientesTableDiv"
}))
Controller:
[HttpPost]
public PartialViewResult Paginacao(int? pagina)
{
...
int numeroPagina = pagina ?? 1; // A pagina está vindo como nula.
int tamanhoPagina = 5;
return PartialView("_ClientesTable",
clientesViewModel.ToPagedList(numeroPagina, tamanhoPagina));
}
Should the last line of the View code be changed?