Question

I have an asp.net form used for search. The search result is showing on the same page using Ajax. If I navigate to another page and come back, I get the populated form but the search result is empty. What's the best way to go back to the page and have the result populated.

Or how to force the page to post back to repopulate the page with the results when back button is clicked?

Was it helpful?

Solution

You can do this using the EnableHistory property on the ScriptManager. Once you've set the ScriptManager's EnableHistory property to True, you can use the AddHistoryPoint method to set history points in your page.

<asp:ScriptManager runat="server" ID="MyScriptManager" EnableHistory="True">
</asp:ScriptManager>

Dino Esposito has a good pair of articles here (client-side) and here (server-side) about using the scriptmanager history functionality.

OTHER TIPS

There are a number of frameworks that attempmt to handle the back button and ajax.
Here is Microsoft 's
Here is one called really simple history

In order to retain the previous selected data on the page user should add the below code:

Response.Cache.SetCacheability(HttpCacheability.NoCache)

in the Page_load event of the page.

So, when the user click the browser back button ,the debugger will come to the page load event of the page, and the user can store the values in Session Variable (Prior Search criteria) and load rebind the Gridview or any server controls.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top