1

I'm learning to make an mvc3 + jquery.ajax product search page. It takes in search keywords and dropdown category filter and returns a datagrid of products as the result, also there is an ajax navigation breadcrumb link like Home>Electronics>LG>BD&DVD Players ... on top of the search results as people filter further into the results. However, once I hit F5(Refresh) button, they are gone as if I first came to the search page.

I can't find a good tutorial on Internet. What is a recommended way to keep the current state of the page in ajax+mvc3? Could you please give me an example, or some link to a good tutorial?

Thank you very much.

EDIT: These are GET data, one solution maybe to add hash like #Home_Electronics_LG_BD_DVD_Players. What if I want POST data, or when I come to filling out a shipping form. Hash # doesn't seem like a solution in that case.

tereško
  • 58,060
  • 25
  • 98
  • 150
Tom
  • 15,781
  • 14
  • 69
  • 111
  • Have you looked into URL Fragments? http://stackoverflow.com/questions/1457/modify-address-bar-url-in-ajax-app-to-match-current-state – Shaun Rowan Apr 22 '12 at 03:00
  • @ShaunRowan Yes, I did a bit of digging. I have just updated the post to point out # hash may be one solution, but what if we are in a POST data situation? – Tom Apr 22 '12 at 03:07
  • Are you expecting the user to be able to type data into a form, hit refresh, and have that data still be populated? That's not how it should work... – Shaun Rowan Apr 22 '12 at 03:21
  • you are right, in a shipping form case refresh button should not keep data. In that case, I am thinking backward and forward buttons. – Tom Apr 22 '12 at 03:30

1 Answers1

0

I believe what you're describing is a "Single Page Application" architecture. Doing an SPA correctly is pretty difficult, so be prepared for a long learning curve.

This page might be helpful to you. It includes a demo SPA application, and a full tutorial.

http://addyosmani.com/blog/building-spas-jquerys-best-friends/

It's in PHP rather than .Net, but it might be helpful with some concepts.

It's worth noting that MVC4 introduces a new SPA framework which might be worth looking into:

http://www.asp.net/single-page-application

Shaun Rowan
  • 9,269
  • 4
  • 28
  • 52