5.1. The Ubiquitous ScriptManager

A ScriptManager is required on every page that you want to use the Microsoft AJAX Library. When the ScriptManager is included in the page, the Microsoft AJAX Library scripts are rendered to the browser. This enables support for using the ASP.NET AJAX Client Library, and by default enables support for partial page rendering. Listing 5-1 (Bare.aspx) is a page with a barebones ScriptManager that does nothing more than render the Microsoft AJAX Library files to the browser.

Example 5-1. Including the ScriptManager (Bare.aspx)
<!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>ASP.NET AJAX ScriptManager</title>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server" />
    <div>
    </div>
    </form>
</body>
</html>

Upon running this page and viewing the rendered HTML source, notice how the rendering changes when the ScriptManager is added to the page. You get five new script elements in the HTML sent to the browser.

The following HTML and JavaScript is part of what is sent to the browser when Bare.aspx is requested. You can see that querystring parameters in the script references are long. They include time stamp elements and unique hash identifiers for script that is registered dynamically. If you copy the path from the src attribute of the script element and paste it into ...

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.