I have a web forms
application that has only one web form. As part of a custom paging
, I have hyperlinks
for each index page under a grid view. These hyperlinks url location are to the same page with index number for the required page appended as query string
.
string url = requestUrl;
int position = requestUrl.IndexOf('?');
if (position > 0)
{
url = requestUrl.Substring(0, position);
}
string link = "<a href='" + url + "?Index=[Index]&Size=[Size]'><span class='page-numbers'>##Text##</span></a>";
Each time a hyperlink for a particular page is clicked, the data will be retrieved from database. Hence I need to pass the search parameters to the new index’s page also. I can pass it as a query string. But the challenge is in some cases the parameter content length can exceed query string limit.
What is the best approach to pass the search parameters to the new page when the hyperlinks are clicked?
Note: A simplified example of paging can be referred in custom-paging-in-asp-net-web-application
Note: The thumb of rule is not to use URLs longer than 2000 characters
EDIT
Based on the answer, I am using LinkButtons instead of Hypelinks. LinkButton
can do a Postback
. Also, I have separated the code in such a way that the pagination logic is in a User Control
. It does not need any business specific data and search parameters. This code can be seen in https://codereview.stackexchange.com/questions/20510/custom-paging-in-asp-net-web-application
REFERENCES: