I am using razor paging and although it works fine because I have lots of subpages I get too many links (1,2,3,4,5 and so on).
Is there any way to display just a few first numbers instead (like 1,2,3 ..... 78)?
Also for this project it would be great to have second paging navigation above the one mentioned consisting of next ane previous buttons. Any ideas how to do this?
Next and previous is pretty simple. Assuming you have a variable called currentPage that holds the current page number and another called totalPages that holds the total number of pages you just do something like this:
Similarly introduce a new variable that holds the currentpage number +5 pages and -5 pages and play with that to skip over paging results. For example when you are on page 50, only show page 45-49 on the left side and 51-65 on the right. When your looping through the pages. So when you're looping through your pages you need to test something like:
razor paging 2 questions
Hi guys,
I am using razor paging and although it works fine because I have lots of subpages I get too many links (1,2,3,4,5 and so on).
Is there any way to display just a few first numbers instead (like 1,2,3 ..... 78)?
Also for this project it would be great to have second paging navigation above the one mentioned consisting of next ane previous buttons. Any ideas how to do this?
kind reagards,
Next and previous is pretty simple. Assuming you have a variable called currentPage that holds the current page number and another called totalPages that holds the total number of pages you just do something like this:
Similarly introduce a new variable that holds the currentpage number +5 pages and -5 pages and play with that to skip over paging results. For example when you are on page 50, only show page 45-49 on the left side and 51-65 on the right. When your looping through the pages. So when you're looping through your pages you need to test something like:
However, you're going to have to add some logic in case you're at page 1-5 or at page 73-78 (if 78 is your highest page).
many thanks for Dan and Sebastiaan,
both solutions work wonders and saved me a lot of time.
cheers!
is working on a reply...