The new ScriptManager is in some sense the brains of an Atlas-enabled ASP.NET page. It provides functionality to both the page developer and the control developer (for those writing Atlas-enabled controls), and it orchestrates partial refreshes, incremental updates, and will do even more in the future. I've seen a couple of questions already around some changes we made in the December build by consolidating functionality into the ScriptManager (the build is up btw at http://atlas.asp.net).
Bootstrapping Atlas
<atlas:ScriptManager runat="server" id="scriptManager" />
Atlas.js (and AtlasCompat.js on non-IE browsers) together bootstrap Atlas functionality on the client browser. The ScriptManager is now responsible for rendering out these references. You no longer need to have a series of <atlas:Script> tags on your page.
Using Atlas in Runtime Mode
<atlas:ScriptManager runat="server" id="scriptManager"
EnableScriptComponents="false" />
As explained in my post a while back there are times when you want a lighter weight version of Atlas, i.e. in what we call
Atlas runtime mode. For example on your site's homepage, where you need minimal script. Alternatively, you may be interested in just the JavaScript OOP patterns, and the ability to talk back to Web services, while coding directly against the raw DHTML DOM. Basically, you want to turn off all the script component support. This is done by referencing AtlasRuntime.js instead of Atlas.js.
Using Atlas in Debug Mode
Starting with this release, we're shipping both Debug and Release flavors of the Atlas scripts. The debug versions have their source formatting preserved, as well as some helpful debug asserts (we will add more over time to improve the error detection experience). ScriptManager detects debug mode as set in configuration in web.config and automatically references the appropriate Atlas scripts.
<system.web>
<compilation debug="true" />
</system.web>
Adding Script References
<atlas:ScriptManager runat="server" id="scriptManager">
<Scripts>
<atlas:ScriptReference ScriptName="AtlasUIGlitz" />
<atlas:ScriptReference Path="Foo.js" Browser="Firefox" />
<atlas:ScriptReference Path="WeatherControl.js" />
</Scripts>
</atlas:ScriptManager>
Previously you had to use several <atlas:Script> controls. All that functionality has been rolled into the Scripts collection of the ScriptManager, so you just have one non-visual control on your page.
Adding Service References
<atlas:ScriptManager runat="server" id="scriptManager">
<Services>
<atlas:ServiceReference Path="ZipCodes.asmx" />
</Services>
</atlas:ScriptManager>
Previously, you had to manually type in a <script> tag with the path to an .asmx followed by "/js". No more. Its much more simpler, and can now be done in design-view as well, without manually typing in script tags. Basically add an item to the Services collection of the ScriptManager, and it will take care of adding the "/js" to the URL as well.
MasterPage/ContentPage Scenarios
You may have a ScriptManager on your master page, but you may want to add additional script or service references in your content page. However, you can only have one ScriptManager on your page. Therefore we have the accompanying ScriptManagerProxy control.
<asp:Content ...>
<atlas:ScriptManagerProxy runat="server" id="scriptManagerProxy">
...
</atlas:ScriptManagerProxy>
</asp:Content>
Support for Atlas-Enabled Server Controls
This deserves a blog post on its own, but I wanted to point out some of the interesting APIs on ScriptManager for control developers. The idea is you have a control that happens to use Atlas for its implementation, and needs to generate XML script to declare and initialize its script-based counterparts on the client.
Getting hold of the ScriptManager instance on the current page:
static ScriptManager ScriptManager.GetCurrent(Page page);
Registering an XML namespace to be rendered out in the XML script markup:
ScriptManager.RegisterScriptNamespace(ScriptNamespace ns);
Registering an Atlas-enabled control (one that implements IScriptControl) so it can be included into the XML script rendering:
ScriptManager.RegisterControl(control);
Registering a script reference so it gets added into the list of script references on the page:
ScriptManager.RegisterScriptReference(FrameworkScript scriptName);
ScriptManager.RegisterScriptReference(string scriptPath);
Note that you can use WebResources to package scripts. Simply pass the URL you get from GetWebResourceUrl to RegisterScriptReference.
And finally, ScriptManager manages the set of UpdatePanels on your page, and performs the work to process post-back requests meant to update just portions of the page, by determining the set of UpdatePanels to update, and rendering parts of the page as needed. I discussed partial rendering in my post from yesterday.
I hope this gives more sense of both Atlas functionality, what is new, and what has changed. You'll see ScriptManager evolve over time to include some even more smarter incremental update mechanisms we've been planning.
Posted on Thursday, 12/22/2005 @ 3:41 PM
| #
ASP.NET