During development, we often encounter a main page that displays data in lists in paging and provides a variety of query conditions. The query result records can be modified, deleted, and other operations. After the operation page is completed, it needs to return to the query page. At this time Query conditions and the current page are often lost. We can solve the problem of losing query page conditions and paging information by saving the page status.
We usually override the protected override object LoadPageStateFromPersistenceMedium() in the Page class,
protected override void SavePageStateToPersistenceMedium(object state),
protected override void RaisePostBackEvent(IPostBackEventHandler sourceControl, string eventArgument),
protected override System.Collections.Specialized.NameValueCollection DeterminePostBackMode(), four methods to solve. However, people generally judge that when restoring the page in the RaisePostBackEvent rewrite, they do not execute the base.RaisePostBackEvent(sourceControl, eventArgument); in order to prevent the event from being re-executed, but this often leads to unexpected situations, such as the modification results not being refreshed. , Deletion records are not refreshed. Although this improves the performance, data refresh cannot solve it. To avoid this problem, the way is very simple, that is, do not rewrite the RaisePostBackEvent and let the query page re-execute the last postback event when the state is restored, so that the results are refreshed. The page condition value and current page index are both preserved. Isn’t it perfect?