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

Robin Pars, Laurence Moroney, and John Grieb

"Foundations of ASP.NET AJAX"

UI.DomElement class. In that example,
the function name was set to the onclick attribute of the button as is often done in classic
JavaScript. We could just as easily use the addHandler method to wire up the click event of
the button to the desired function.
The addHandler method has three required parameters: the target element, the name
of the event, and the event handler. So in the case of the previous sample, we would have
Sys.UI.DomElement.addHandler(Button1, "click", repositionPanel);
or by using the $addHandler shortcut, we would have
$addHandler(Button1, "click", repositionPanel);
CHAPTER 4 ?–  ASP.NET AJAX CLIENT LIBRARIES 75
In such a case, another thing that would have to be different is the function signature
of the click handler. It must now have support for the event object and the following signature:
function eventHandler (e) {??¦}
With that, we get all the added benefits of being able to extract potentially useful data
out of the event object. Speaking of useful data, take a look at the fields of the
Sys.UI.DomEvent class in Table 4-18.
Table 4-18.


Pages:
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140