[[ajax_--_o_reily]] Blue Lotus

Route:


AJAX -- O'Reily

Javascript is not strong typed.
Javascript may be emeded in web pages in three ways: scripts, event handler and URLs.
Array is a special kind of variable. var days = new Array("s", "dd");
for (var day in days) same as foreach in c#
JS doesn't support function overloading, however the number of arguments in a functino is not fixed.
Anonymous function like: window.onload = function () {}
Js is object-based language, not an object-oriented one.
A class in Js is implemented by creating a function. The code within this function is the class constructor. All class properties and methods are defined within the class code. The this keyword provies access to the properties of the current class.

function Book(isbn)
{
var _isbn = isbn; this.get_isbn = function () { return _isbn; }
}
var atlas = new Book("aaa");
atlas.get_isbn();

To let a class inherit from another one, the following expression must be used:
DerivedClass.prototype = new BaseClass();
Note that there are no protected properties, so all private properties from the base class must be defined again.

XMLHttpRequest Object
1. Create an XMLHttpRequest object
2. Call the object's open() method to provide the data for the request.
3. Provide a callback function in the onreadystatechange property
4. Send the HTTP request with the send method

var XMLHTTP = getXMLHTTP();
if (XMLHTTP != null)
{
XMLHTTP.open("GET", "ajax.aspx?sendData=ok"); XMLHTTP.onreadystatechange = function() { if (XMLHTTP.readyState == 4 && XMLHTTP.status = 200) { window.alert(XMLHTTP.responseText); } }; XMLHTTP.send(null);
}


JSON
JavaScript Object Notation
JSON is internally used by Atlas and can generally be used to easily exchange complex data with a server.
it is much easier to write a JSON parser
JavaScript itself, JSON can be parsed trivially using the eval() procedure


{ "book" : {
"title": "Atlas jampstart", "author": "Christian Wenz" }
}
eval("var obj = " + json + ";");


Cache can take load of server. To avoid caching
1. append a fake GET parameter to the XMLHttpRequest call
2. set an additional reqeust header for the HTTP request

Atlas Client-side Controls
Sys.UI namespace
Handling control events
1. call the initialize() method of the elemenet to capture events
2. write an event handling function
3. Link the event handling function to the element using <element>.<event name>.add(<method name>)

XML-script
a special markup format. using inline XML is the best idea to provide data binding.

Behaviors
It ties an action to an HTML element
Sys.UI.PopupBehavior
Sys.UI.ClickBehavior
Sys.UI.HoverBehavior
Sys.UI.AutoCompleteBehavior

Component
is something that is not bound to HTML elements on a page, but are standalone. They aggregate a set of JavaScript functionality provide an interface to use it in code.

Custom Behaviors and Components
1. Implement the standard methods getDescriptor() (which exposes all properties) and dispose() (to clean up)
2. Register the class you implemented using Type.registerSealedClass(0 and let it inherit from Sys.Component.
3. Finally, add your component type using Sys.TypeDescriptor.addType() so that you can use it from within XML-script

Client-Script Library OOP Extensions
NameSpaces
Inheritance
Abstract Classes
Interfaces

Client-Side versions of .NET classes
Sys.StringBuilder
Enumerations

Extending Controls
Adding Drag and Drop to a Control
Adding Autocomplete to a Control
Making a Section Updateable (UpdatePanel)

Atlas Control Toolkit
The Atlas Control Toolkit was created in order to allow both Microsoft and ASP.NET community to easily and non-core functionality to the framework independent of the Atlas update cycle. The Toolkit will ultimately contain 50 to 100 Atlas controls from Microsoft.

Writing Custom Controls

ajax_--_o_reily, Rev. 3, Last changed on 2006-08-13 20:40, 436 page hits
Wiki hosted for free at wikihost.org || RSS-Feed || GeboGebo 1.3.3 || 00.418 seconds || || PAGERANK TOOLS