1
I’m using Pagedlist with Ajax, but I can’t change the page because when I click on the button, which 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));
}
The code of the last line of the View must be changed?
Thanks Virgilio! It worked, but it generated another problem hehe. The first link does not generate the same settings as the other links (href, data-ajax, ...), so you do not have how to request the controller.
– Raphael