Last post Jul 09, 2018 07:49 AM by Abraham Qian
Jul 06, 2018 03:38 PM|0belix|LINK
I have a form with multiple filters that reacts to the filters using JQuery and AJAX.
The filters are of various type, like checkboxes, and also a more complex filter that uses an input text field to add multiple strings that get added as anchors inside a div.
Whenever the user adds a filter (it can be a new check status of a checkbox, adding of removing a text filter, etc, my JS function captures all the filters data and calls a webmethod via AJAX that loads the results according to the filters.
When the user presses any of the results, it gets taken to another page, and this is where the issue starts.
If the user then presses the back button, he gets taken back to the form, but none of the filters status persists, so basically the user needs to redo all the filters again in order to get the same results.
Here's a working example of how the filters work:
Is there a way for the browser to keep not only the checkboxes statuses but also the added anchors (and any other form field status)?
I've read about 'localstorage', but i'm not sure if this applies to my case, since i do not have any querystring on the URL.
Any ideias guys?
Jul 07, 2018 04:57 AM|vinz|LINK
That's normal since your JS resides within your browser, and the browser won't be able to persist the data on postbacks. You would need to store the filter information in a persistent storage such as Session, Cookies or Database so you can reference them
back across post backs and page reloads.
Also, if you are targeting HTML 5 users, you can try using the autocomplete attribute just like what is suggested here: https://stackoverflow.com/questions/14420624/how-to-keep-changed-form-content-when-leaving-and-going-back-to-https-page-wor
Jul 07, 2018 03:33 PM|mudassarkhan|LINK
When using AJAX the data fetched using is not stored in History of browser and hence nothing will be loaded.
So either you can save the User data on Server side in Session so that it can be loaded or you can use HTML5 Session Storage to locally save data in browser.
Jul 09, 2018 07:49 AM|Abraham Qian|LINK
According to your description, I think we could add the previous filter status to the Asp.Net global variable, Such as Session, Cookie. If you are using H5, I suggest you could use localstorage to store your information on the client. So you could access
these data even after postback.
Here is tutorial, wish it is useful to you.
Feel free to let me know if you have any questions.