开发者

ScriptManager.AddHistoryPoint - page is displaying original page state first, then saved state

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 h开发者_如何学Pythonere 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?


as I know in ScriptManager event OnNavigateHistory you must handle there that example you add HistoryPoint for state one and two same key ID only the value is different and thene OnNavigateHistory base on e.State["YourKey"] you make decision wich state to stay. example

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

Sorry for my bad english

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜