6.4. Adding History Support
Now that you have seen the AJAX enabled application, you are ready to see how start controlling the navigation history. History support is built into the framework, but it is disabled by default because it performs some initialization on the page that would be unnecessary if you weren't using the feature. For example, it requires a hidden IFRAME to work on some browsers, which is created for you automatically. To enable history support, set the EnableHistory property on the ScriptManager.
<asp:ScriptManager id="ScriptManager1" runat="server" EnableHistory="true" />
Figure 6-3. Figure 6-3
When using history there are two tasks you are mainly concerned with: creating history points and handling navigation events. To create a history point, you associate a value with it by calling the AddHistoryPoint method on the ScriptManager.
ScriptManager1.AddHistoryPoint(key, value, title);
The value is important because you use it to restore state when a navigation event occurs. History maintains values as a list of key-value pairs, so it is possible for multiple components on a page to maintain history points without interfering with one another, if they use different keys. In addition to the key and value, you can optionally associate a title with the history point, which will appear as the page title in the browser's history.
When the user uses one of the history ...
Get Professional ASP.NET 3.5 AJAX now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.