■ CONTENTS
xiv
Using Partial Views ..................................................................................................... 401
Creating and Rendering a Partial View ..............................................................................................401
Rendering a Partial View Using Server Tags......................................................................................406
Summary..................................................................................................................... 408
■Chapter 12: Models and Data Entry...................................................................409
How It All Fits Together............................................................................................... 409
Templated View Helpers ............................................................................................. 410
Displaying and Editing Models Using Templated View Helpers .........................................................411
Using Partial Views to Define Custom Templates ..............................................................................422
Model Metadata .......................................................................................................... 427
Working with Data Annotations..........................................................................................................428
Creating a Custom Metadata Provider ...............................................................................................429
Consuming Model Metadata in Custom HTML Helpers......................................................................433
Using [MetadataType] to Define Metadata on a Buddy Class ............................................................434
Model Binding ............................................................................................................. 434
Model-Binding to Action Method Parameters ....................................................................................435
Model-Binding to Custom Types ........................................................................................................436
Invoking Model Binding Directly ........................................................................................................439
Model-Binding to Arrays, Collections, and Dictionaries.....................................................................441
Creating a Custom Value Provider .....................................................................................................444
Creating a Custom Model Binder .......................................................................................................445
Using Model Binding to Receive File Uploads....................................................................................449
Validation .................................................................................................................... 450
Registering and Displaying Validation Errors.....................................................................................450
Performing Validation As Part of Model Binding ................................................................................456
Specifying Validation Rules................................................................................................................458
Invoking Validation Manually .............................................................................................................464
Using Client-Side Validation...............................................................................................................465
Putting Your Model Layer in Charge of Validation..............................................................................472
Summary..................................................................................................................... 476