You can get the base url from Model.PreviousUrl and Model.NextUrl using Regex. Here is how I handled it.
//ensures that logic has a url to work with if the index is at the end or the beginning
string baseUrl = Model.PreviousUrl.IsNullOrWhiteSpace() ? Model.NextUrl : Model.PreviousUrl;
//regex to filter out the pagination query strings
Regex clipPage = new Regex(@".+(?=\?p=\d+$)");
//removes the query string from the base url
baseUrl = clipPage.Match(baseUrl).Value;
Then to link to a particular page you just use @(baseUrl)?p={page} where {page} is the page number.
Also, be sure to use cpi in your for loop, as Model.CurrentPageIndex +1 will be constant for the whole loop.
Thank you for this, I have managed to make some head way with this now as a result of your response, thank you.
My last hurdle is to now restrict the numerical results based on actual available pages plus to not show the - (Minus) symbol next to the negative previous pages (most don't actually exist), this is my code so far:
Articulate Pager on list.cshtml view, show current page number but be a link to respective page of article?
Hi,
I have the pager rending newer & older correctly and I have made use of the numeric value
This shows the number of pages of articles however they are not linked so when I click the number the respective page of articles does not show?
So taking the above, I need to wrap this in a link that is the current
for example and not
How can I get the Blog's Root Url as the PagerModel does not allow for
I was planning on setting this as a variable of say rootUrl & then use this to populate the variable for the pageUrl
So far I have tried the following with no luck, almost but just this last bit:
Any advice or suggestions appreciated.
You can get the base url from Model.PreviousUrl and Model.NextUrl using Regex. Here is how I handled it.
Then to link to a particular page you just use @(baseUrl)?p={page} where {page} is the page number.
Also, be sure to use cpi in your for loop, as Model.CurrentPageIndex +1 will be constant for the whole loop.
Hope that helps.
@Jesse Andrews,
Thank you for this, I have managed to make some head way with this now as a result of your response, thank you.
My last hurdle is to now restrict the numerical results based on actual available pages plus to not show the - (Minus) symbol next to the negative previous pages (most don't actually exist), this is my code so far:
It's starting to look good:
Solution:
is working on a reply...