Keep client side class changes between ASP.Net postbacks?

I dynamically link tables and sub-tables using nested lists. On the client side, I have a piece of jQuery that switches the visibility of TRs in tables to allow for expanding group / contract.

In postback, I obviously lose my changes to the class that I applied through jQuery. I am wondering what is the best approach to maintaining these client side class changes? I considered the possibility of creating hidden input control in a table to store the indices of visible TRs at the time of their expansion. The goal is then to search for indexes during postback / rebinding and add visible classes to each corresponding element.

Is there a better approach or some kind of proprietary way to pass the name / class on the client side during postback?

+3
source share
1 answer

There are several ways to do this:

  • As you suggest, a hidden control containing information about changes in the viewing state, the server side then uses this information to display correctly the next time, or javascript looks at this information when the page loads and adjusts the page. If you want the data to be stored in sessions (log entries), you need the server information to store the information in the database and display it on each page.
  • , , ajax . , , . , , (, , ), , , .
  • : cookie. , .
+5

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


All Articles