For my partner, Chelsea Knowles
—T
ony
n
orThrup
For my wife, Carrie Snell
—M
ike
S
nell
Contents at a Glance
Acknowledgments xxv
Introduction xxvii
Introducing ASP.NET 4 1
Using Master Pages, Themes, and Caching 41
Handling Events and Managing State 97
Using Server Controls 161
Input Validation and Site Navigation 227
Globalization and Accessibility 291
Creating Custom Web Controls 329
Debugging and Deploying 387
Working with Client-Side Scripting, AJAX, and jQuery 453
Writing and Working with HTTP Modules
and Web Services 551
Connecting to and Querying Data with LINQ 623
Working with Data Source Controls
and Data-Bound Controls 685
Implementing User Proles, Authentication,
and Authorization 787
Creating Websites with ASP.NET MVC 2 831
Answers 881
Index 925
About the Authors 967
Contents
Contents at a Glance vii
Contents
Hardware Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xxviii
Software Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xxviii
Using the Companion Media . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xxviii
How to Install the Practice Tests xxix
How to Use the Practice Tests xxix
How to Uninstall the Practice Tests xxxi
Microsoft Certied Professional Program . . . . . . . . . . . . . . . . . . . . . . . . . .xxxi
Errata and Book Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xxxi
We Want to Hear from You . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxxii
Stay in Touch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxxii
Before You Begin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Lesson 1: Understanding Web Communications . . . . . . . . . . . . . . . . . . . . . . 3
The Web Server’s Role 4
The Web Browser’s Role 5
Understanding the Role of HTTP 5
Lesson Summary 14
Lesson Review 14
Lesson 2: Creating a Website and Adding New Webpages . . . . . . . . . . . . . 15
Creating Websites 15
Creating ASPX Pages 23
Website Compilation 28
Using Assemblies 29
Lesson Summary 31
Lesson Review 31
Contents
Contents ix
Lesson 3: Working with Web Conguration Files . . . . . . . . . . . . . . . . . . . . . 32
Understanding the Conguration File Hierarchy 33
Processing the Conguration Files 34
Changes to .NET Framework 4 Conguration Files 34
Editing Conguration Files 34
Lesson Summary 38
Lesson Review 38
Case Scenarios . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
Case Scenario 1: Creating a New Website 39
Case Scenario 2: Placing Files in the Proper Folders 39
Suggested Practices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
Create a New Website by Using Visual Studio 2010 39
Add a Webpage to the Website 40
Program a Web Application 40
Examine Settings for a Web Application 40
Take a Practice Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
Before You Begin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
Lesson 1: Using Master Pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
Overview of Master and Content Pages 44
Creating a Master Page 45
Creating Content Pages 47
Attaching Master Pages to Content Pages 48
Referencing Custom Master Page Properties, Methods,
and Controls from Content Pages 48
Creating Nested Master Pages 51
Dynamically Changing Master Pages 52
Lesson Summary 58
Lesson Review 59
Lesson 2: Using Themes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
Themes Overview 60
Creating a Theme 61
Creating a Skin File 64
Adding a Cascading Style Sheet to Your Theme 65
Rules for Applying Themes 66
Applying a Theme Programmatically 67
Lesson Summary 73
Lesson Review 74
Lesson 3: Caching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
Application Caching 75
Page Output Caching 80
Programmatically Invalidating Cached Pages 85
Lesson Summary 91
Lesson Review 91
Case Scenarios . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
Case Scenario 1: Providing Consistent Formatting
for an External Web Application 92
Case Scenario 2: Improving the Performance of
a Public Website 93
Suggested Practices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
Implement Master Pages and Themes 94
Implement Caching 95
Take a Practice Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
Before You Begin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
Lesson 1: Understanding the ASP.NET Life Cycle
and Handling Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
The ASP.NET Application Life Cycle 100
Understanding the Life Cycle of an ASP.NET Webpage
and Its Controls 103
Lesson Summary 119
Lesson Review 119
Lesson 2: Using Client-Side State Management . . . . . . . . . . . . . . . . . . . . . 120
Choosing Client-Side or Server-Side State Management 121
View State 123
Hidden Fields 128
Cookies 129
Query Strings 133
Lesson Summary 141
Lesson Review 142
Lesson 3: Using Server-Side State Management . . . . . . . . . . . . . . . . . . . . . 143
Application State 144
Session State 145
Lesson Summary 154
Lesson Review 154
Case Scenarios . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
Case Scenario 1: Selecting the Proper Events to Use 155
Case Scenario 2: Remembering User Credentials 156
Case Scenario 3: Analyzing Information for Individual
Users and for All Users 156
Suggested Practices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
Respond to Application and Session Events 157
Create Event Handlers for Pages and Controls 157
Manage State by Using Client-Based
State Management Options 158
Manage State by Using Server-Based
State Management Options 158
Maintain State by Using Database Technology 158
Take a Practice Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
Before You Begin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162
Lesson 1: Exploring Common Server Controls . . . . . . . . . . . . . . . . . . . . . . . 163
Web Server Controls 163
The Label Control 167
The Literal Control 169
The TextBox Control 171
The CheckBox Control 172
The RadioButton Control 172
The DropDownList Control 173
The ListBox Control 175
The Button Control 175
HTML Server Controls 177
Lesson Summary 184
Lesson Review 185
Lesson 2: Exploring Specialized Server Controls . . . . . . . . . . . . . . . . . . . . . 186
The Table, TableRow, and TableCell Controls 187
The Image Control 189
The ImageButton Control 191
The ImageMap Control 192
The Calendar Control 197
The FileUpload Control 202
The Panel Control 205
The MultiView and View Controls 207
The Wizard Control 210
The Xml Control 214
Lesson Summary 223
Lesson Review 223
Case Scenarios . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224
Case Scenario 1: Determining the Type of Controls to Use 225
Case Scenario 2: Determining How to Prompt for Data 225
Case Scenario 3: Implementing a Calendar Solution 225
Suggested Practices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226
Implement Server Controls 226
Take a Practice Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226
Before You Begin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228
Lesson 1: Performing Input Validation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228
Understanding the Validation Framework 229
Understanding the RequiredFieldValidator Control 232
Using the CompareValidator Control 232
Using the RangeValidator Control 234
Using the RegularExpressionValidator Control 234
The CustomValidator Control 235
Lesson Summary 244
Lesson Review 244
Lesson 2: Performing Site Navigation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245
Is Page Navigation Necessary? 246
Choosing a Method to Navigate Pages 246
Client-Side Navigation 247
Cross-Page Posting 248
Client-Side Browser Redirect 250
Server-Side Transfer 251
Using the Site Map Web Server Control 252
Lesson Summary 259
Lesson Review 259
Lesson 3: Using Web Parts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260
What Are Web Parts? 261
The WebParts Namespace 263
Dening Web Part Zones 264
Creating Web Parts 265
Enabling Users to Arrange and Edit Web Parts 266
Connecting Web Parts 269
Personalizing Web Parts 274
Lesson Summary 286
Lesson Review 286
Không có nhận xét nào:
Đăng nhận xét