I want to use MvcAjaxPager Nuget package. As I understood it is a helper that could page and specify URL by default.
But if you want to send with AJAX you should add jQuery. Pager and jQuery. Path. So added these.I want paging so that when user clicks on the buttons (1,2,3,...),connect to server (reseller Pages 2) with AJAX and get partial View from server.
It happened! but not with AJAX! I realized that my helper (Ajax Pager) works
perfectly and pager function is called back perfectly too.but it looks like that pager function does not work normally.why?
This is my view:
@using MvcAjaxPager
@model IEnumerable<MvcInternetShopp.Models.DomainModel.representative>
@{
ViewBag.Title = "ResellerPages";
}
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Name)
</td>
<td>
@Html.DisplayFor(modelItem => item.City.Name)
</td>
<td>
@Html.DisplayFor(modelItem => item.Ostan.Name)
</td>
<td>
@Html.DisplayFor(modelItem => item.Address)
</td>
<td>
@Html.DisplayFor(modelItem => item.Phone)
</td>
</tr>
}
</table>
</div>
<div id="x"></div>
@Html.AjaxPager(11, 2, 1, "ResellerPages2", "Home", null, new PagerOptions
{
LastPageText = "آخر",
AjaxUpdateTargetId = "x",
Id="Pager"
}, null,null)
<script src="~/Scripts/jquery-3.2.1.js"></script>
<script src="~/Scripts/jquery.pager-1.0.2.js"></script>
<script src="~/Scripts/path.js"></script>
@section Scripts{
<script>
$(function () {
$("#Pager").pager();
})
</script>
}
And this is my controller:
public ActionResult ResellerPages(int page = 1)
{
var model = blRepresentative.Select().OrderBy(p => p.Id).Skip((page - 1) * 2).Take(2);
return View(model);
}
public ActionResult ResellerPages2(int page = 1)
{
var model = blRepresentative.Select().OrderBy(p => p.Id).Skip((page - 1) * 2).Take(2);
return PartialView("_ResellerPages2",model);
}