Prev | Current Page 536 | Next

Rob Cameron and Dale Michalk

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

Ch09.HoverButton,
{text: 'A HoverButton Control', //properties
element: {style: {fontWeight: "bold", borderWidth: "2px"}}}, //properties
{click: doClick, hover: doSomethingOnHover,
unhover: doSomethingOnUnHover}, //events
null, //references (none in this case)
$get('Button1')); //element where the behavior is applied
}
The $create method is a shortcut to the Sys.Component.Create method in the ASP.NET
AJAX client library. Here is the syntax of the call:
$create(type, properties, events, references, element);
From the preceding example, the type is ControlsBook2Lib.Ch09.HoverButton found in
HoverButton.js. The type parameter is mandatory. The properties, events, references, and
element parameters are optional but will most likely be present if the component is going to do
something useful. The value must be in JavaScript Object Notation (JSON) format for the properties,
events, references, and element parameters, which explains why the syntax is not very
familiar (but the comments in the text just before this paragraph identify the parameters). For more
information on JSON, please refer to the ASP.NET AJAX client-side library documentation.
The third parameter, events, is interesting since the rest of the JavaScript in HoverButton.


Pages:
524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548