Prev | Current Page 540 | Next

Rob Cameron and Dale Michalk

"Pro ASP.NET 3.5 Server Controls and AJAX Components"

aspx, initializeBase is called
when the page is run, which then calls initialize on the HoverButton prototype. The prototype
provides the meat of the class, wiring up event handlers, and so on, as well as clean-up via a
dispose method. Listing 9-6 contains the JavaScript from HoverButton.js.
Listing 9-6. The HoverButton.js Script File
Type.registerNamespace("ControlsBook2Lib.Ch09");
//HoverButton Constructor
ControlsBook2Lib.Ch09.HoverButton = function(element)
{
ControlsBook2Lib.Ch09.HoverButton.initializeBase(this, [element]);
this._clickDelegate = null;
this._hoverDelegate = null;
this._unhoverDelegate = null;
}
//HoverButton Prototype
ControlsBook2Lib.Ch09.HoverButton.prototype =
{
// text property accessors.
get_text: function()
{
return this.get_element().innerHTML;
},
set_text: function(value)
{
this.get_element().innerHTML = value;
},
// Bind and unbind to click event.
add_click: function(handler)
{
this.get_events().addHandler('click', handler);
},
424 CHAPTER 9 ?–  ASP.NET A JAX CONTROLS AND EXTENDERS
remove_click: function(handler)
{
this.get_events().removeHandler('click', handler);
},
// Bind and unbind to hover event.
add_hover: function(handler)
{
this.get_events().addHandler('hover', handler);
},
remove_hover: function(handler)
{
this.


Pages:
528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552