刚安装完Atlas后发现在C:\Program Files\Microsoft ASP.NET\Atlas\v2.0.50727\Atlas\ScriptLibrary下生成了Atlas使用的脚本库,看了几个例子还是迷惑沉沉,于是看了下ScriptLibrary如下的文档,终于对脚本库有了个整体上的了解,真是茅塞顿开
Introduction
The 'Atlas' client library is a set of Javascript (.js) files that make up an object-oriented class library for building enhanced user interfaces (UI) for ASP.NET applications. The purpose of the client library is to simplify the process of building AJAX applications with rich UI's that work across browsers.
What is Included in the Client Library
The client library is physically made up of a set of .js files packaged as resources in the 'Atlas' assembly file. If you run the 'Atlas' installer, it will place a copy of the assembly (named Microsoft.Web.Atlas.dll) in a selected installation folder. You can add this assembly to the bin folder of a Web application, and this will enable you to access 'Atlas' functionality both on the server, and the script library files which are referenced as standard client-side scripts. If you have run the 'Atlas' installer, you can examine the contents of the .js files in the client library. There are both debug and deployment versions of all the files. Go to the install location you selected, and find the folder named ScriptLibrary. A typical local installation path is:
..Program Files\Microsoft ASP.NET\Atlas\v2.0.50727\Atlas\ScriptLibrary
The following .js files are included in the 'Atlas' client library:
- AtlasRuntime.js. The 'Atlas' runtime file is the most basic, minimal script that you can use to run 'Atlas' features. It contains essentially the most minimal set of 'Atlas' features: web services, networking services, and the basic object-oriented extensions to Javascript. To minimize the amount of script being downloaded, you can reference only this script when you do not need the full set of 'Atlas' client-side controls and functionality. The runtime script is useful when you just want to call Web services from JavaScript, to write your own script that gathers parameters, makes the call, and handles the results. The section below on using the 'Atlas' client library explains how to reference the runtime file only.
- Atlas.js. The Atlas.js file contains the full 'Atlas' feature set, and it includes the 'Atlas' runtime by default. Atlas.js adds to the runtime features the full set of 'Atlas' client components and controls, plus the 'Atlas' declarative syntax for specifying data-binding and client UI details. This is the most commonly used library script, and it is included by default when you add an 'Atlas'
ScriptManagercomponent to a page. See the next section on using the 'Atlas' client library. - AtlasCompat.js. Provides cross-browser compatibility for 'Atlas' features.
- AtlasCompat2.js. Provides cross-browser compatibility for 'Atlas' features.
- AtlasFX.js. Contains the same content as Atlas.js, but without the included AtlasRuntime.js code. This is for use with gadgets in hosted scenarios.
- AtlasUIDragDrop.js. Implements the drag and drop feature.
- AtlasUIGlitz.js. Implements special UI effects.
- AtlasUIMap.js. Implements a virtual mapping feature.
- AtlasWebParts.js. Implements 'Atlas' features for use with ASP.NET Web Parts controls.
- GadgetRuntime.js. Runtime code used by Microsoft and MSN.
The client library consists of four logical layers:
- Javascript extensions. The Javascript extensions add a number of objects, functions, and data types to native Javascript. Registration methods enable you to create simulated OO constructs such as classes, namespaces, enumerations, inheritance, and interface implementation.
- Base class library. The base class library is a set of commonly used classes for debugging, handling events, handling strings, web services, accessing the host environment, timers, and components.
- Core UI framework. The Core UI framework includes building block objects for the UI infrastructure and for interacting with the DOM and DHTML. This includes a base control object; a set of behaviors; validation; data binding; client-side content templates; drag and drop; and other UI effects.
- UI toolkit. The UI toolkit contains a set of individual, client-side controls that have richer capabilities than standard HTML controls. These include many typical controls, such as: hyperlink, listview, select, dataview, button, checkbox, textbox, label, datasource, counter, and more.
Using the 'Atlas' Client Library Scripts
Every page that uses 'Atlas' functionality must have access to the client library. The mechanism for accessing the client scripts is the 'Atlas' ScriptManager control. Every page with 'Atlas' features must have one (and only one) ScriptManager control on the page. By default, the ScriptManager control automatically includes a reference to the main Atlas.js file (which also includes a reference to the more basic AtlasRuntime.js file).
This is the most common of all 'Atlas' development scenarios, when you need a reference to the standard 'Atlas' script components (the 'Atlas' client-side components, controls, and declarative syntax created by the Atlas.js file) because you are using either an 'Atlas' server control or 'Atlas' client controls in your code. When you need the 'Atlas' script components, as you do in most common development cases, the following declarative ScriptManager reference by default gives you the needed reference to Atlas.js:
<atlas:ScriptManager id="scriptManager1" runat="server" />
In some cases, when you need to reference different client library scripts, you must declare the ScriptManager control differently. Following are some common scenarios for declaring scripts.
Specialized script reference scenarios
- Using the AtlasRuntime.js. When you want a smaller download size on your page, and you are only calling to Web services from script (meaning that you do not need all the 'Atlas' client components), you can call only the AtlasRuntime.js file, excluding all others. To do this, declare the
ScriptManagercontrol like the following example:
Setting the<atlas:ScriptManager id="scriptManager1" runat="server" enablescriptcomponents="false" />enablescriptcomponentsattribute to false means that the default scenario (which loads Atlas.js and AtlasRuntime.js) does not occur, and only AtlasRuntime.js is referenced on the page. - Using the compatibility scripts. You never need to invoke the compatibility scripts; they are called automatically when needed for a particular client browser.
- Using special features. To use special 'Atlas' features, such as drag and drop or UI effects, you must reference the specialized scripts by name. Currently, several of the 'Atlas' scripts can be referenced by name, including
AtlasUIDragandDrop,AtlasUIGlitz,AtlasUIMap, andAtlasWebParts. A reference that includes two of these scripts looks like the following example:
Note that when you reference these specialized scripts, you reference them by name only, and not with a .js file extension. To reference a custom .js script, assign a value of<atlas:ScriptManager id="scriptManager1" runat="server">
<scripts>
<atlas:scriptreference scriptname="AtlasUIDragDrop" />
<atlas:scriptreference scriptname="AtlasUIGlitz" />
</scripts>
</atlas:ScriptManager>customto thescriptnameattribute, and then add apathattribute and provide a path to the custom script.
浙公网安备 33010602011771号