Prashant Nagouda
Prashant Nagouda

Reputation: 21

Browser back button is not showing changes on same page in Asp.Net page

I have a Asp.Net application. There is one search.aspx page to filter the content using check boxes. I have used jQuery to filter the content in the application.When I filter through check boxes the URL remains same ie search.aspx.

My issue is when I click on the browser back button previous filter results are not being displayed, instead I'm returned to Home.aspx.

How can I navigate back and forth through the filters using the browsers forward/back buttons?

Upvotes: 1

Views: 325

Answers (1)

Basic
Basic

Reputation: 26766

If you're not changing the page but filtering purely in Javascript, you'll need to manually manage the browser history through Javascript. There's a new HTML5 feature designed for this (History/State APIs) and it's possible to fudge it in older browsers.

Consider using something like history.js which will do a lot of the work for you.

Fundamentally, you'll be modifying the url using, either using the area after the hash to store state (old-style) or a normal parameters (new-style)

Eg:

/Search.aspx#Term=Some+Term
/Search.aspx?Term=Some+Term

Here's am example of the technique that uses history.js

Upvotes: 2

Related Questions