1

I'm using an UpdatePanel and the ScriptManager's AddHistoryPoint method to save my page state in the browser's history. The page is a simple search/results page with 2 states:

  • STATE 1 - showing search filters
  • STATE 2 - showing search results

When I navigate back to the page (by clicking the back button in my browser), the page shows the initial state (STATE 1) but then the update panel posts back and the page flips to the search results (STATE 2).

This looks untidy and it feels like I'm missing something here in my implementation. How can I tell the page to either just load the saved state, or hide the page content until the saved state has been loaded?

4

1 回答 1

0

正如我在 ScriptManager 事件 OnNavigateHistory 中所知道的那样,您必须在那里处理那个示例,您为状态一和两个相同的键 ID 添加 HistoryPoint,只是值不同,然后 OnNavigateHistory 基于 e.State["YourKey"] 您做出决定保持状态。例子

string indexString = e.State["YourKey"]; 
    if (String.IsNullOrEmpty(indexString)) { 
         SetToStateOne();
    }
    else { 
        int index = int.Parse(indexString); 
        SetToStateTwo();
    }

对不起,我的英语不好

于 2010-07-28T19:40:14.910 回答