I have the following code that puts the number of pages, but the problem is that if the number of pages is many, it will expand to the end of the page. Is it possible to make the number of pages only 5 buttons?
Currently, it appears to me as the following image: enter image description here
<nav aria-label="Page navigation example">
<ul class="pagination">
@{
int TotalPage = ViewBag.TotalPage;
int PageNumber = ViewBag.PageNumber;
if (TotalPage > 1)
{
for (int i = 1; i <= TotalPage; i++)
{
if (PageNumber == i)
{
<li class="page-item active">
@Html.ActionLink(i.ToString(), "Index", "MyMission", new { area = "Task", PageNumber = i }, new { @class = "page-link" })
</li>
}
else
{
<li class="page-item">
@Html.ActionLink(i.ToString(), "Index", "MyMission", new { area = "Task", PageNumber = i }, new { @class = "page-link" })
</li>
}
}
}
}
</ul>
</nav>