I'm displaying a list of filtered items in a page, and now I have to limit the displaying by paginating the results.
So if I have url parameters like these:
example.com/?category=pizza&period=today
where both category and period can also not being showed:
example.com/?period=today
example.com/
how can I add a "Next page" in the end that keeps any previous parameter and adds
&pagenum=5
or if there are no parameters:
?pagenum=5
Tnx in advance!
Add a WHERE clause that contains the fields you want to add parameters to. If a WHERE clause already exists, check to see whether the fields you want to add parameters to are already in the clause. If they aren't, add them. Note that you need to add the same filter to each section of the query.
URL parameters (also known as “query strings”) are a way to structure additional information for a given URL. Parameters are added to the end of a URL after a '? ' symbol, and multiple parameters can be included when separated by the '&' symbol.
Using [FromUri] To force Web API to read a complex type from the URI, add the [FromUri] attribute to the parameter. The following example defines a GeoPoint type, along with a controller method that gets the GeoPoint from the URI.
For serverside
string url = Request.Url.GetLeftPart(UriPartial.Path);
url += (Request.QueryString.ToString() == "" ) ? "?pagenum=1" : "?" + Request.QueryString.ToString() + "&pagenum=1";
You can pass in the page number depending on how you are handling this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With