■ CONTENTS
xviii
Creating an Unobtrusive Ajax Form ........................................................................ 577
Preparing the Controller ................................................................................................. 577
Creating the Ajax Form .................................................................................................. 578
Understanding How Unobtrusive Ajax Works ................................................................ 580
Setting Ajax Options ............................................................................................... 581
Ensuring Graceful Degradation ...................................................................................... 581
Providing the User with Feedback While Making an Ajax Request ................................ 583
Prompting the User Before Making a Request ............................................................... 584
Creating Ajax Links ................................................................................................ 585
Ensuring Graceful Degradation for Links ....................................................................... 587
Working with Ajax Callbacks .................................................................................. 587
Working with JSON ................................................................................................. 590
Adding JSON Support to the Controller .......................................................................... 590
Processing JSON in the Browser ................................................................................... 591
Preparing Data for Encoding .......................................................................................... 593
Detecting Ajax Requests in the Action Method .............................................................. 595
Summary ................................................................................................................ 598
Chapter 22: Model Binding ..................................................................................... 599
Preparing the Example Project ............................................................................... 599
Understanding Model Binding ................................................................................ 601
Using the Default Model Binder .............................................................................. 603
Binding to Simple Types ................................................................................................ 603
Binding to Complex Types ............................................................................................. 607
Binding to Arrays and Collections .................................................................................. 614
Manually Invoking Model Binding .......................................................................... 619
Dealing with Binding Errors ........................................................................................... 621
Customizing the Model Binding System ................................................................. 621
Creating a Custom Value Provider ................................................................................. 622
Creating a Custom Model Binder ................................................................................... 625
Registering the Custom Model Binder ........................................................................... 627
Summary ................................................................................................................ 628
Chapter 23: Model Validation ................................................................................. 629
Creating the Example Project ................................................................................. 629
Explicitly Validating a Model .................................................................................. 631