This feature set is not used
by our samples, so it will be set to null.
The Callback Web Form
The Callback web form in Figure 8-11 shows an example of the client callback feature when
implemented via code on a web form. The somewhat contrived example shows a DropDownList
control holding vehicle category data linked in a parent-child hierarchy with a ListBox control
displaying vehicles from several manufacturers. Changes to the category in the DropDownList
refresh the vehicles displayed in the ListBox according to that category. The top set of controls
uses the traditional approach to the solution with an automatic postback control with serverside
data binding changes while the bottom set uses client-side callback features to refresh the
data without a postback. The clock at the top of the page confirms whether a postback was
incurred or not.
CHAPTER 8 ?– INTEGRATING CL IENT-SIDE SCRIPT 397
Figure 8-11. The Callback web form client callback example
The key function in the web form code is a utility function named RenderScripts. The first
thing it does is add client-side JavaScript code to detect a select element change from the
rendered DropDownList named CbCategoryDrp and then tie its selected value to an invocation of
a function named GetVehicles.
Pages:
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517