views:

229

answers:

2

Having a site where you can search with the below snippet, how do you store the history for each search so that a user can press the back-button to get to previous search results and have a populated text-box with the searched values?

<% using(Ajax.BeginForm("TestSearch", 
       new AjaxOptions { UpdateTargetId = "details" })) { %>


    <%= Html.TextBox("search") %>

    <input type="submit" value="search" />

<% } %>
+1  A: 

Not quite sure if that's enough for what you need, but I guess you need something like one of these plugins: http://stackoverflow.com/questions/116446/what-is-the-best-back-button-jquery-plugin.

queen3
A: 

Here is a decent jQuery, ASP.NET, and Browser History article explaining exactly what you need to do -

http://stephenwalther.com/blog/archive/2010/04/08/jquery-asp.net-and-browser-history.aspx

The article takes advantage of the following four JavaScript files:

1.jQuery-1.4.2.js – The jQuery library. Available from the Microsoft Ajax CDN at http://ajax.microsoft.com/ajax/jquery/jquery-1.4.2.js

2.jquery.pager.js – Used to generate pager for navigating records. Available from http://plugins.jquery.com/project/Pager

3.microtemplates.js – John Resig’s micro-templating library. Available from http://ejohn.org/blog/javascript-micro-templating/

4.jquery.ba-bbq.js – The Back Button and Query (BBQ) Library. Available from http://benalman.com/projects/jquery-bbq-plugin/

Kris Krause