JQuery / ASP.Net - How to maintain state of hidden user interface elements through backward copies?

I am working on a web form with various controls. Depending on user input, I show / hide the GUI bit (using the jQuery show () / hide () functions). However, if the form is submitted back and does not pass the test, I want the GUI to remain in the same state as before, and not return to the first load state. It is obvious that ASP.Net controls are stateless, but I have HTML containers that are pure client-side objects.

Trying to develop a solution, I find myself heading towards the dark (and difficult to debug) areas of the hidden form fields - more reminiscent of my work in front of JQuery than anything in the 21st century :-(

Can anyone suggest a better way ...?

+3
source share
2 answers

If anyone reads this:

I went with a jQueryish solution - now the JS function works already. It checks the status of any ASP.Net controls that act as "visibility controllers" (which maintain their own state through callbacks) and accordingly configure the interface through jQuery calls.

+1
source

I think the trick is to use hidden fields to maintain the state of the fields on the client side.

So, the process looks something like this:

user action -> update hidden values ​​-> update interface

Then, when the page is sent back, you reinstall the user interface:

Page loading → interface update

0
source

Source: https://habr.com/ru/post/1785955/


All Articles