Primer
This is an extremely difficult question, just describes it, it will be very difficult, but I try it, I hope to describe it clearly:
Our company is a page logic using List / Detail, that is, a DataGrid lists, lists some items, click one of them, page jumps to the Detail page to see the details. The Detail page has a return button and returns to the list page after clicking. The data list in the list is usually filtered, such as XXX greater than 20, and then sorted.
The question is like this:
User requirements, when returning from Detail to LIST, the state in the data list is unchanged.
The company believes that this is a reasonable requirement, because the amount of data is too big, no one wants to return to List, you have to look from the first page.
Also required, the Detail project just watching must be the current page of the list of List, not necessarily the page of the previous list data list; but if the current item is deleted in Detail, return must be entered That page of the List data list.
What is more trouble is that users may jump to several related pages, these related pages may also have DataDrid, and then users will be held in the corresponding Detail page.
And there may be multiple DataGrids in a list page.
For example:
The user views A_LIST, A_LIST has DataGrid_a1 and DataGrid_a2, the data is filtered; then he views the data of the item A1.1, which enters A1.1_Detail; then jump into the A1.1 related Page A1.1_Detail2, this page has a DataGrid_a1.1, he performs screening, sorting; jump into another related page of A1.1, this page is a list page A1.1_List, where there is DataGrid_a1.11, it is obvious The data of this page is also filtering, the user sorts him; then enter one of the Detail page A
1.11.1
, Modify the data ...
Ok, after these, he returned. First returned to A1.1_LIST, requiring DataGrid_a1.11 screening conditions, sorting the way, the one just visited on the DataGrid current page, before this item is on the second page, now may be on page 4 , Then display the fourth page; then return to a1.1_detail2, DataGrid_a1.1 screening conditions on this page, sort mode, the current page number is constant; return to A1.1_DETAIL, delete this A1.1 data; Finally returned to A_LIST, at this time, the screening conditions of the two DataGrid on this page are required, and the sorting mode is unchanged, and all previous page numbers are displayed.
More terrible is that the real user does not necessarily return to the original road, so don't want these page status data to follow the principle of advancement.
What should I do?
Reasons for this problem
If it is in a Windows program, this is very simple, because from the first, a recorded Detail and its related information, usually a plurality of tabs of a form; even if you open another form, it is just It's just that you have hide it, you can go out when you return. In the final analysis, the Windows program is a stateful application, everything is very simple.
It is different from the Web. The web is stateless. Every time the page is returned, I don't know what the value is before, let alone the page, every page, I don't know my own Where (which page) is coming. problem analysis
Such a difficult problem, watching dizzy, but to solve the problem, still have to use the awake brain.
Basic Thoughts: Save the status data of the previous web page, jump to a new page, save the status data of the front page, and then retrieve the original data when returned.
Let's take a look at the interaction data between the page.
In general, it is the way of using URL parameters, but here is obviously lost, the URL has a length limit, and so many parameters, the assembly of the URL string will let your headache die.
What should I do, I have to use another way:
When you jump from a page, don't use RESPONSE.REDIRECT, and apply Server.Transfer, then use Context.Handler in the target web page, as shown below:
The class of the previous web page is ABC, and the latter page is dbc.aspx.
Define public fields in the previous webline ABC
PUBLIC STRING CCC;
So use when jumping in ABC
Server.Transfer (dbc.aspx)
Use the latter web page
((ABC) Context.Handler. CCC can take a corresponding value.
But it is obvious that there is still a problem in this, lacks versatility. What should I do with multiple page jumps? And the context.handler.gettype () method is unused, an exception occurs.
Then define the interface.
Define data on the need to interpret in an interface, multiple web pages implement the same interface.
Query parameters, sort conditions, the current page to display, or display item IDs in the current page ... are defined in the implementation of the interface.
But the problem is that the page is running while jump, and the data will continue to accumulate. If you jump from List1 to Detail1, then jump to list2, then jump to Detail2, this time Detail2 To save the data of the three web pages in front, These three web pages implements the same interface, which may result in the case where the data is covered.
In general, when this is the case, it is designed a stack-like data structure. When it enters a new web page, the data of the original web page is pushed into the stack, which is called the protection site.
It is a pity that this is not used, because the user will not necessarily return, if you use the way forward, you will find a web page to retrieve your own data but find that you can't retrieve it, you can get yourself The data.
Only an array is used, and this array is still dynamic.
Then, modify the interface just now, change it into a class DataInfo, then implement an interface, there is a dynamic array in the interface to store DataInfo.
However, the element of the dynamic array is Object, which is too wide. I hope to strictly, only allow storage rather than messy stacks in the array, if you really implement a dynamic array, then you send DataInfo in the inside, I The stuff in the inside, it is still not taking a set.
Then, the plurality of outsides the population, so that it only allows storage of DataInfo. Can't pack directly in the interface, because I want to join some code to check if it is only DataInfo, or what is the other Dongdong. What should I do, then customize a class DataInfolist. And these classes are marked as serializable, which can be sequenced so that the status can be saved in ViewState. (Endlessly)