CHAPTER 4 ?– ASP.NET AJAX CLIENT LIBRARIES 74
Sys.UI.DomEvent
Sophisticated event handling has long been a major weakness of web applications in
general when compared to the rich and stateful desktop applications. The ASP.NET AJAX
Client Library takes a major step in closing the gap (to some extent) from a functional
standpoint between the event modeling in .NET Framework and client-side ASP.NET.
Sys.UI.DomEvent provides a browser-agnostic model packed with useful properties and
events that can be easily used with DOM elements. This comes in particularly handy considering
the fact that browsers at times differ in their API and handling of DOM events.
Table 4-17 lists the methods of the Sys.UI.DomEvent class.
Table 4-17.Methods of the Sys.UI.DomEvent Class
Method Name Description
addHandler Adds a DOM event handler to the DOM element; also aliased by the
$addHandler shortcut
addHandlers Adds a list of DOM event handlers to the DOM element; also aliased by
the $addHandlers shortcut.
clearHandlers Removes all DOM event handlers from the DOM element that were
added through the addHandler or the addHandlers methods; also aliased
by the $clearHandlers shortcut
preventDefault Prevents the default DOM event from executing
removeHandler Removes a DOM event handler from the DOM element that exposes
the event; also aliased by the $removeHandler shortcut
stopPropagation Stops the propagation of an event to its parent elements
In the previous script sample, you saw how to move a panel around the screen with
client-side only code using the methods of the Sys.
Pages:
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139