Last week we
surveyed Microsoft’s answer to the AJAX buzz in the form of Atlas. Basically, Atlas
is an ASP.NET 2.0 framework for building cross-browser, cross-platform AJAX
Microsoft recently released the April Community Technology
Preview and stated that it feels it is ready for a go live license. With that
in mind, this week we’ll examine the centerpiece of Atlas: the ScriptManager class.
The center of attention
The ScriptManager class manages
all Atlas components on a Web page. In addition, it handles partial page
updates, and renders client scripts that enable you to access Web service
Every page that utilizes Atlas components must contain only
one ScriptManager control, which is declared in the
head portion of a Web page. It registers the Atlas scripts, making them
available on the page. If you’re using ASP.NET 2.0, then you can include a ScriptManager control on a master page, thus making it
available to all pages that use that master page. The ScriptManager
control uses the syntax in
Let’s take a closer look at various aspects of declaring a ScriptManager control:
- EnablePartialRendering: This attribute signals whether
partial rendering is enabled. Partial rendering is used to reload only
portions or sections of a page. If true, regular postbacks
from asynchronous controls are present with only incremental changes sent to
- EnableScriptComponents: This attribute controls which
parts of Atlas are available on the client by default. It determines
whether Atlas scripts for user-interface components, behaviors, databinding, and XML scripting are downloaded to the
client by default. If false, you can download specific components in the ScriptReference element.
- ScriptReference: This element (which must be
enclosed in a Scripts element) allows you to add scripts that are not
included automatically. Scripts are designated with the Path attribute,
and you may specify a browser for that script with the Browser attribute.
Atlas does include some scripts that are not sent to the client by
default; these may be included with the ScriptName
attribute. These scripts include AtlasUIDragDrop,
AtlasUIGlitz, and AtlasUIMap.
- ServiceReference: This element allows you to
designate Web services that may be used in scripts on the page. The Type
attribute can be any valid MIME type. The GenerateProxy
attribute allows you to temporarily disable the generation of proxy
objects for services listed in the Scripts collection.
The Web page in
Listing B utilizes a local Web service (although it could be any service). The page declares the Web service reference that is later
disabled, as well as the loading of all script libraries. The ScriptReference section references the AtlasRuntime
script library (installed with Atlas), so basic functionality is available. The
source code for the service is in
Using more than one ScriptManager control
While you are restricted to one instance of a ScriptManager control on a Web page, you may want to add
additional script or service references to a page. In this scenario, the ScriptManagerProxy control is provided.
This control may be useful if you need to utilize additional
scripts (ScriptReference element) when a ScriptManager object has already been declared. A good
example involves ASP.NET 2.0 and placing a ScriptManager
object on a master page. Pages that utilize the master page may need to utilize
additional scripts, so the proxy object is available. It uses the same syntax
as the regular ScriptManager control.
While the ScriptManager control is
the focal point of Atlas-based Web pages, the framework includes a few controls
out-of-the-box to enhance a Web page with little programming. Here is an
overview of the controls included with the most recent edition of Atlas:
- AutoCompleteExtender: Allows you to extend text box
controls to provide auto-completion behavior. A Web service is used to
provide the suggestion data.
- DragOverlayExtender: You can turn a server control
into a floating control that may be moved with the mouse/keyboard.
- ProfileScriptService: Creates a client-side profile
component for access to ASP.NET user profiles.
- TimerControl: Creates a client-side timer that
performs a postback at regular intervals.
There are many examples on the Atlas Web site, but the DragOverlayExtender
control is one of the coolest and easiest to implement. Basically, you create a
control and assign it to an instance of the DragOverlayExtender
control’s TargetControlID property to get it working.
The example in
demonstrates its use by allowing an image to be moved around the page.
System administrators are unnecessary to work with
Atlas—you can simply copy the Microsoft.Web.Atlas.dll file into your projects’
\bin directory and copy the Atlas \ScriptLibrary
directory of .js files into your project and
everything is ready to go.
Also, while Atlas does have the Microsoft label, it was
designed to be browser agnostic. All styling for Atlas-based controls is
accomplished with CSS. In addition, Atlas allows you to develop
browser-specific content if necessary.
Finally, some argue that Atlas is simply a ploy to steer
developers away from Firefox and Opera, which continue
to gain market share in the browser space. While I’m sure Microsoft is aware of
its competitors’ actions, I don’t worry too much about the software giant’s
motives; I just want technology that allows me to build powerful solutions for
my clients. Atlas may (or may not) fill that need when it is finally release,
but I like what I see to date.
While the Atlas framework has not been officially released
as a product, the latest technology preview gives you an idea of what to
expect. You should understand that Atlas simplifies AJAX development with the ScriptManager control at its nucleus. Everything you do
with Atlas will utilize this control, so you should be familiar with its usage
and options when working with Atlas-based solutions.
Tony Patton began his professional career as an application developer earning Java, VB, Lotus, and XML certifications to bolster his knowledge.
Miss a column?
Check out the Web Development Zone archive, and catch up on the most recent editions of Tony Patton’s column.