ASP.NET MVC 2 Cookbook

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

Written in cookbook style, this book offers solutions to all common web development problems through recipes. Each recipe contains step-by-step instructions followed by the analysis of what was done in each task and other useful information. The book is designed so that you can read it chapter by chapter, or you can look at the list of recipes and refer to them in no particular order. This book is particularly written for web developers looking to transfer their knowledge from the ASP.NET Web Forms way of doing things to the ASP.NET MVC framework. As this book targets readers of various experience levels, you should be able to find recipes of a basic, intermediate, and advanced nature. Regardless of your experience level, each recipe will walk you through the solution in a step by step manner that anyone should be able to follow.

Author(s): Andrew Siemer, Richard Kimber
Publisher: Packt Publishing
Year: 2011

Language: English
Pages: 332
Tags: Библиотека;Компьютерная литература;ASP.NET / MVC / Web Services;ASP.NET MVC;

Cover......Page 1
Copyright......Page 3
Credits......Page 4
About the Authors......Page 5
About the Reviewers......Page 6
www.PacktPub.com......Page 8
Table of Contents......Page 10
Preface......Page 14
Introduction......Page 20
Using magic strings and the ViewData dictionary......Page 21
Creating a strongly typed view......Page 26
Decoupling a strongly typed view with a View model......Page 29
Centralizing display logic with templated helpers......Page 33
Using a partial view to segment view code......Page 35
Rendering a child view with Html.RenderAction......Page 43
Loading a view template from a database with NVelocity......Page 48
Consuming a JSON with jQuery......Page 53
Introduction......Page 58
Exposing JSON using a JsonResult with Json.NET......Page 59
A custom ActionResult to return an image......Page 61
Specifying the size of an ImageResult......Page 65
Creating a CAPTCHA system......Page 71
Generating a PDF order summary......Page 76
Implementing a controller factory for use with StructureMap......Page 79
Introduction......Page 86
Creating a route to support a reporting engine......Page 87
Making hackable URLs for a product catalog......Page 89
Filter your matches with routing constraints......Page 93
Using wildcard parameters to support slug URLs......Page 95
Creating a 404 page via routing......Page 96
Moving routes out of Global.asax......Page 100
Supporting pagination in your URLs......Page 102
Supporting content hierarchies with a custom RouteHandler......Page 108
Creating a blacklist route constraint......Page 112
How to create a master page......Page 118
Determining the master page in the ActionResult......Page 122
Controlling which master page is used with a view base class......Page 123
Setting the master page from a controller base class......Page 124
Passing data to the master page......Page 126
Rendering data in a master page from another view......Page 128
Creating nested master pages......Page 130
Introduction......Page 132
Reintroducing for and foreach......Page 133
Handling an array of checkboxes......Page 139
Handling an array of radio buttons......Page 141
Working with a pageable set of data......Page 143
How to navigate sortable data......Page 145
Deleting a record with an intermediary "Are you sure?" page......Page 150
Adding a jQuery delete link with confirmation......Page 153
Master/detail page with inline details via jQuery and a partial view......Page 157
Creating a master/detail page with modal pop-up and JSON......Page 161
Introduction......Page 166
Using HTML helpers to create forms......Page 167
Building a custom HTML helper to display a WYSIWYG......Page 170
Centralizing create and edit forms for reuse......Page 176
Adding custom attributes to form elements......Page 179
Defining a default button with jQuery......Page 180
Hijaxing a form with jQuery......Page 183
Performing an auto post-back with a select list......Page 188
Autocomplete with jQuery UI......Page 191
Introduction......Page 196
Centralized formatting of common types with templated helpers......Page 197
Making templated helpers for custom types......Page 200
Using areas to separate application components......Page 204
Creating a "portable area" to use across multiple applications......Page 205
Using input builders of MvcContrib......Page 211
Generating forms with Html.InputForm()......Page 215
Leaving breadcrumbs for your users with MvcSiteMap......Page 217
Displaying tabular data in a grid......Page 220
Basic input validation......Page 224
Data annotations......Page 229
Client-side validation with jQuery......Page 231
Custom validators......Page 233
Remote validation with jQuery......Page 236
Introduction......Page 244
Mocking your data layer with NBuilder......Page 245
Adding support for LINQ to SQL......Page 257
Going old school with ADO.NET......Page 270
XML documents as a data store......Page 276
Introduction......Page 286
Keeping track of anonymous visitors versus logged-in users......Page 287
Maintaining a user's information while at your site......Page 292
Remembering a previous visitor......Page 295
Caching your product catalog for faster response times......Page 300
Using output caching to cache an entire page......Page 305
Using partial views to cache pieces of a page individually......Page 309
Exposing an application API to your presentation layer......Page 318
Index......Page 324