SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 81 | Next

Robin Pars, Laurence Moroney, and John Grieb

"Foundations of ASP.NET AJAX"

You can use
these to build objects in JavaScript and assign them to the namespaces for clearer, easierto-
read, and easier-to-debug code. Listing 3-1 shows the definition of the Car class you
used earlier. This class is registered to the AJAXBook namespace.
CHAPTER 3 ?–  THE MICROSOFT AJAX LIBRARY: MAKING CLIENT-SIDE JAVASCRIPT EASIER 41
Listing 3-1. Creating a Car Namespace
Type.registerNamespace("AJAXBook");
AJAXBook.Car = function(strMake, strModel, strYear)
{
this._Make = strMake;
this._Model = strModel;
this._Year = strYear;
};
AJAXBook.Car.prototype =
{
get_Make: function()
{
return this._Make;
},
get_Model: function()
{
return this._Model;
},
get_MakeandModel: function()
{
return this._Make + " " + this._Model;
},
get_Year: function()
{
return this._Year;
},
dispose: function()
{
alert("Bye");
}
};
AJAXBook.Car.registerClass("AJAXBook.Car");
CHAPTER 3 ?–  THE MICROSOFT AJAX LIBRARY: MAKING CLIENT-SIDE JAVASCRIPT EASIER 42
In the code, the namespace AJAXBook is registered using the Type.registerNamespace
method..registerNamespace command.


Pages:
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93