Reputation: 1625
I am currently working on a site for an auto dealer and ran into a bit of a snag when I started trying to ad pagination to the inventory page.
The inventory page has 5 search options type, make, year, model and trim. They are all drop downs and they are all populated by a live feed, changing the options autopostback the page and the inventory/nav are updated accordingly.
Everything was working great until I went to add pagination to the page. The pagination works fine for what it is, if there are more then 15 results it adds a numbered nav to the page that allows the user to jump pages.
<a href="search.aspx?page=4">4</a>
The problem is when they do jump pages all of the search options revert to there original settings, and when the page loads its pulling in every car again instead of what the user searched for. I can't really figure out what the issues is, I expect the state is getting lost when the user clicks the link even though it is to the same page. I tried using sessions but it seems to have muddied it up, does anyone have any suggestions for a fix?
If you require the code I can link it, I warn you though it is a pretty large amount of code and I don't think you could find much in it, but who knows.
Upvotes: 0
Views: 114
Reputation: 1969
If you don't want to use a sever side control, you could always pass the search parameters in the query string.
<a href="search.aspx?page=4&Make=Ford&Model=Mustang&Year=2010">4</a>
If you do it this way, please be sure to sanitize your inputs before you pass them back to the database.
Upvotes: 0
Reputation: 23878
Try using a LinkButton control with an OnClick event. Do whatever you are doing when you test for the "page=4" querystring parameter in the OnClick event. You are losing state because the a regular html anchor tag causes the page to load as if it were the first time you visited and ViewState is blown away - Page.IsPostback is false.
Upvotes: 1