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 90 | Next

Robin Pars, Laurence Moroney, and John Grieb

"Foundations of ASP.NET AJAX"

");
theCar.set_CurrentGear(5);
alert(theCar.get_MakeandModel()
+ " is now cruising in gear number: "
+ theCar.get_CurrentGear());
}
else
{
alert("Current Car: "
+ theCar.get_MakeandModel()
+ " This is an imitation sports car "
+ " -- it's an automatic with a sleek body.");
}
}
CHAPTER 3 ?–  THE MICROSOFT AJAX LIBRARY: MAKING CLIENT-SIDE JAVASCRIPT EASIER 48
This method checks to see whether the car being passed is a ???real??? sports car. It does
this by checking whether it implements the IStickShift interface using the method AJAXBook.
IStickShift.isImplementedBy(), which returns true only if the specified object is an
instance of a class that implements the IStickShift interface. After it is determined that
the car object implements the interface, then it is safe to call the methods set_Current-
Gear() and get_CurrentGear(). If an attempt was made to call the methods and they didn??™t
exist, an exception would be thrown.
You can see the application in action in Figure 3-12.
Figure 3-12. Implementing the IStickShift interface
Accessing Server Resources from JavaScript
A typical design pattern in web applications is consuming a web service and presenting
the data it returns to the user.


Pages:
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102