1.7. The ScriptManager ControlAfter this first working example, here is some more background information about how this example worked, and how the other Atlas examples throughout the book work. The central element of an Atlas-powered ASP.NET page is the ScriptManager, <atlas:ScriptManager>. This control takes care of loading the required JavaScript libraries of Atlas, depending on which browser is used. If you look at the resulting source code in the browser, you will see that Atlas changed very littleonly the <atlas:ScriptManager> element has been replaced with this code (the undecipherable data in the URL will be a bit different on your system): <script src="/books/3/491/1/html/2//Atlas/WebResource.axd?d=EiZ5MhryFS7wRPgWKwT3L2TYwCkaaO5mtAO5KyVbAcNmREm0baC0S _edhhqj_Y6ZuRY56z97Nu5lD2Fw5ITB3mHpybsGTsINHdsdQ_BVGi7cUBG1EWW_cWGx-I8vZeWK0 &t=632781806040000000" type="text/javascript"></script> <script src="/books/3/491/1/html/2//Atlas/WebResource.axd?d=EiZ5MhryFS7wRPgWKwT3L2TYwCkaaO5mtAO5KyVbAcNmREm0baC0S _edhhqj_Y6ZuRY56z97Nu5lD2Fw5ITB3g4TEhGZLS-_Daibixpp8tw1&t=632781806040000000" type="text/javascript"></script> <script src="/books/3/491/1/html/2/atlasglob.axd" type="text/javascript"></script> The first <script> tag is used only in non-IE browsers to add a compatibility layer; the second one loads the Atlas core library. The third <script> element contains some client-specific culture information.
This ScriptManager element must be present on all pages that use Atlas features. It can also be used to load additional JavaScript libraries, either those that come with Atlas, or your own scripts: <atlas:ScriptManager runat="server"> <Scripts> <atlas:ScriptReference Path="MyScript.js" /> </Scripts> </atlas:ScriptManager> If you are using ASP.NET 2.0 master pages and most of your pages use the Atlas framework, you may consider putting the ScriptManager control on your master page instead of on the individual pages. However when referencing other JavaScript files or web services (as in the "Hello User" example earlier), you run into problems: only one ScriptManager control is allowed per page, so you would have to reference the JavaScript file or web service on all pages, even on those that do not need these external resources. For this scenario, Atlas provides the ScriptManagerProxy control. This control provides ScriptManager functionality when there is already another ScriptManager present: <atlas:ScriptManagerProxy runat="server"> <Scripts> <atlas:ScriptReference Path="MyScript.js" /> </Scripts> </atlas:ScriptManagerProxy> This was just the first step; there's more to come in the following chapters! |