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.8. Adding History Support

Adding history support is just a matter of calling the equivalent client-side APIs on the Sys.Application client class instead of the ScriptManager. Listing 6-7 (AlbumSearchClientHistory.aspx) shows the necessary changes.

Example 6-7. AlbumSearchClientHistory.aspx
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/
    TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Phish Album Search</title>
    <script type="text/javascript">
    var Albums = [
        { title: "A Live One", date: "1995/06/27" },
        { title: "Hampton Comes Alive", date: "1999/11/23" },
        { title: "Live In Vegas", date: "2002/11/12" },
        { title: "Vida Blue", date: "2002/06/25" },
        { title: "The Illustrated Band (Vida Blue)", date: "2003/10/14" }
    ];

    function onSearch() {
        var term = $get('txtSearch').value.toLowerCase();
        var title = 'Phish Album Search - "' + term + '"';
        Sys.Application.addHistoryPoint({ term: term }, title);
    }

    function executeSearch() {
        var term = $get('txtSearch').value.toLowerCase();
        var results = [];
        for (var i = 0; i < Albums.length; i++) {
            var album = Albums[i];
            if (album.title.toLowerCase().indexOf(term) !== −1) {
                results.push(album);
            }
        }
        printResults(results);
        var title = 'Phish Album Search - "' + term + '"';
        document.title = title;
    }

    function printResults(results) {
        var list = $get('albumList');
        list.innerHTML = "";

        var sb = new Sys.StringBuilder();
for (var i = 0; ...

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