Chapter 16. Using Behaviors and Components
Handling events with script code or xml-script can be a practical way to create user experiences that are more interactive, but sometimes this approach just requires too much code. This is especially true when you wish to tie a specific action to a particular control, such as one that is a reaction to a user clicking or hovering over it. Fortunately, ASP.NET AJAX offers viable alternatives that will be introduced and discussed in this chapter: ASP.NET AJAX behaviors and components.
Whereas ASP.NET AJAX behaviors contain JavaScript functionality and are always tied to visible HTML page elements, ASP.NET AJAX components, which consist of JavaScript, might or might not have a graphical representation. One example of this, the Timer
control was discussed in Chapter 6, which demonstrated an instance of a component that is not represented graphically on the page.
In this chapter, we will explore the behaviors and components that ship with the ASP.NET AJAX Futures release and demonstrate how to use them.
Using Behaviors
ASP.NET AJAX behaviors are similar to those introduced by Microsoft for Internet Explorer in that you can attach a predefined ASP.NET AJAX behavior to an HTML element just as you can attach an Internet Explorer behavior. For instance, one behavior that ships with Internet Explorer allows you to do something when the mouse pointer hovers over an element, such as a button, perhaps altering its color or font.
The ASP.NET AJAX Futures release ...
Get Programming ASP.NET AJAX now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.