O'Reilly logo

Professional ASP.NET 3.5 AJAX by Matt Gibbs, Dan Wahlin, Bill Evjen, Dave Reed

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required