ASP.Net Ajax in Action

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"

Ajax has revolutionized the way users interact with web pages today. Gone are frustrating page refreshes, lost scroll positions and intermittent interaction with a web site. Instead, we have a new generation of fast, rich, and more intuitive web applications. The ASP.NET AJAX framework puts the power of Ajax into the hands of web developers. ASP.NET AJAX, formerly called Atlas, is a new free framework from Microsoft designed to easily add Ajax features to ASP.NET applications. With this technology, ASP.NET developers can easily build more interactive and highly-personalized web applications that work across all most popular browsers. ASP.NET AJAX in Action is a fast-paced, example-rich tutorial designed for ASP.NET web developers and written by ASP.NET AJAX experts Alessandro "Garbin" Gallo, David Barkol, and Rama Krishna Vavilala. This book introduces you to Ajax applications and to the ASP.NET AJAX technology. Beginners will appreciate the clear explanations of key ideas and terminology. Intermediate and advanced ASP.NET developers will find a no-nonsense learning source and well-organized reference. ASP.NET AJAX in Action offers a rich set of examples and meticulous explanations. The extensive code samples are accompanied by accurate and rigorous explanations of the concepts behind development with ASP.NET AJAX. In this book, you will discover how to useMicrosoft Ajax Library Partial rendering with UpdatePanels Advanced client and server techniques Ajax Control Toolkit If you are a web developer looking to bring your web pages to life and to enhance the user experience, this book is for you. ASP.NET AJAX in Action will give you with the knowledge and tools you need to more easily craft the next generation of Ajax applications. With the help of the Microsoft ASP.NET AJAX framework, Ajax development has never been easier and more instinctive for both client-script developers and ASP.NET developers alike. Purchase of the print book comes with an offer of a free PDF, ePub, and Kindle eBook from Manning. Also available is all code from the book.

Author(s): Alessandro Gallo, David Barkol, Rama Vavilala, Scott Guthrie, Bertrand Le Roy
Publisher: Manning Publications
Year: 2007

Language: English
Pages: 561

ASP.NET AJAX in Action......Page 0
brief contents......Page 3
contents......Page 5
forewords......Page 13
preface......Page 17
about the authors......Page 27
ASP.NET AJAX basics......Page 31
Introducing ASP.NET AJAX......Page 32
1.1 What is Ajax?......Page 33
1.1.1 Ajax components......Page 34
1.1.2 Asynchronous web programming......Page 36
1.1.3 The XMLHttpRequest object......Page 39
1.1.4 Ajax development issues......Page 43
1.2 ASP.NET AJAX architecture......Page 44
1.2.1 Client framework......Page 45
1.2.2 Server framework......Page 48
1.2.3 Client-centric development model......Page 49
1.2.4 Server-centric development model......Page 50
1.2.5 ASP.NET AJAX goals......Page 51
1.3.1 Simple server-centric solution......Page 52
1.3.2 UpdateProgress control......Page 57
1.3.3 Simple client-centric example......Page 59
1.4 Summary......Page 63
First steps with the Microsoft Ajax Library......Page 65
2.1.1 Library features......Page 66
2.1.2 Ajax-enabling an ASP.NET page......Page 68
2.1.3 Script versions......Page 69
2.2 The Application model......Page 71
2.2.1 Client components......Page 72
2.2.2 Client-page lifecycle......Page 73
2.2.3 “Hello Microsoft Ajax!”......Page 74
2.3.1 The abstraction API......Page 77
2.3.2 A dynamic, cross-browser text box......Page 78
2.3.3 CSS and positioning......Page 82
2.3.4 Client delegates......Page 83
2.3.5 $addHandlers and $clearHandlers......Page 85
2.3.6 Callbacks......Page 86
2.4.1 The String object......Page 87
2.4.2 Sys.StringBuilder......Page 88
2.4.3 The Array object......Page 90
2.4.4 Globalization......Page 92
2.4.5 Browser detection......Page 94
2.4.6 Debugging......Page 95
2.4.7 Typed errors......Page 98
2.5 Summary......Page 101
JavaScript for Ajax developers......Page 102
3.1 Working with objects......Page 103
3.1.1 Objects......Page 104
3.1.2 Arrays......Page 105
3.1.3 Functions......Page 106
3.1.4 Creating custom objects......Page 110
3.1.5 The prototype object......Page 111
3.1.6 Extending a JavaScript type......Page 112
3.1.7 Literals......Page 114
3.2.1 JSON structures......Page 115
3.2.2 JSON and the Microsoft Ajax Library......Page 117
3.3.1 Client classes......Page 118
3.3.2 The registerClass method......Page 119
3.3.3 Properties......Page 120
3.3.4 Namespaces......Page 122
3.4.1 Prototype-based inheritance......Page 124
3.4.2 Passing arguments to the base class......Page 126
3.4.3 Overrides......Page 127
3.5.1 Interfaces......Page 128
3.5.2 Enumerations......Page 130
3.6.1 Reflection methods......Page 133
3.6.2 Object typing......Page 134
3.6.3 Building a simple class browser......Page 135
3.7 Working with events......Page 137
3.7.1 Exposing an event......Page 138
3.7.2 Subscribing to and handling events......Page 141
3.8 Summary......Page 142
Exploring the Ajax server extensions......Page 143
4.1.1 What are the Ajax server extensions?......Page 144
4.2 Enhancing an existing ASP.NET site......Page 145
4.2.1 A sample ASP.NET site......Page 146
4.2.2 Configuring an existing ASP.NET site......Page 147
4.3 ScriptManager: the brains of an Ajax page......Page 149
4.3.1 Understanding the ScriptManager......Page 150
4.3.2 Deploying JavaScript files......Page 151
4.3.3 Registering services......Page 152
4.3.4 Localization......Page 153
4.3.5 Using the ScriptManagerProxy......Page 155
4.4 Partial-page updates......Page 156
4.4.1 Introducing the UpdatePanel control......Page 157
4.4.2 More UpdatePanels......Page 160
4.4.3 Insert feedback here......Page 162
4.4.4 Working with a timer......Page 164
4.4.5 Error handling......Page 167
4.5 Summary......Page 169
Making asynchronous network calls......Page 170
5.1 Working with ASP.NET Web Services......Page 171
5.1.1 Configuring a web service......Page 172
5.1.2 Invoking web service methods from JavaScript......Page 175
5.1.3 Managing complex types......Page 179
5.1.4 Using HTTP GET......Page 187
5.1.5 Page methods......Page 188
5.2 The asynchronous communication layer......Page 189
5.2.1 A simple WebRequest......Page 190
5.2.2 The executor......Page 191
5.2.4 Handling errors......Page 192
5.3 Consuming external Web Services......Page 195
5.3.1 The script technique......Page 196
5.3.2 Cross-domain calls through the server......Page 197
5.3.3 Mash-it-up with ASP.NET AJAX......Page 198
5.3.4 Bridges......Page 204
5.4.1 Enabling ASP.NET application services......Page 212
5.4.2 Authentication service......Page 213
5.4.3 Profile......Page 216
5.4.4 Roles: an Orcas preview......Page 220
5.4.5 Message board application......Page 221
5.5 Summary......Page 222
Partial-page rendering with UpdatePanels......Page 223
6.1.1 Evolution of the UpdatePanel......Page 224
6.1.2 A simple example......Page 225
6.2.1 Content for the UpdatePanel......Page 230
6.2.2 Update modes......Page 232
6.2.3 Render modes......Page 234
6.2.4 ASP.NET page lifecycle......Page 236
6.3.1 Asynchronous triggers......Page 237
6.3.2 Postback triggers......Page 239
6.3.3 Manual triggers......Page 240
6.4.1 Repeating UpdatePanels......Page 242
6.5 Live GridView filter......Page 245
6.5.1 Live GridView filter goals......Page 246
6.5.2 How does the GridView filter work?......Page 247
6.5.3 Adding Ajax to the GridView filter......Page 252
6.5.4 It’s alive!......Page 253
6.6 Summary......Page 256
Advanced techniques......Page 257
Under the hood of the UpdatePanel......Page 258
7.1 The PageRequestManager: the unsung hero......Page 259
7.1.1 The client-side event model......Page 260
7.1.2 The anatomy of an asynchronous postback......Page 263
7.2 A client-side event viewer......Page 270
7.2.1 Getting started......Page 271
7.2.2 Handling client-side events......Page 272
7.2.3 Aborting a postback......Page 277
7.2.4 Managing postback priority......Page 278
7.2.5 Notifying the user......Page 279
7.2.6 Locked and loaded......Page 280
7.2.7 Client-side error handling......Page 282
7.3.1 Why is the UpdatePanel slow?......Page 283
7.3.2 Inject JavaScript during a partial postback......Page 285
7.3.3 Getting the validators to work......Page 287
7.3.4 Sys.WebForms.PageRequestManagerParseErrorException......Page 288
7.4 Caveats and limitations......Page 289
7.5 Summary......Page 290
ASP.NET AJAX client components......Page 291
8.1 The client component model......Page 292
8.1.1 Visual and nonvisual components......Page 294
8.1.3 Component lifecycle......Page 295
8.1.4 Containers......Page 296
8.2 Working with client components......Page 297
8.2.1 Creating components......Page 300
8.2.3 Events and property change notification......Page 303
8.3 Behaviors......Page 306
8.3.1 Sys.UI.Behavior......Page 307
8.3.3 Accessing behaviors......Page 308
8.3.4 Enhancing a text box element......Page 309
8.4.1 Sys.UI.Control......Page 314
8.4.2 Creating controls......Page 315
8.4.4 Creating an element wrapper: text box......Page 316
8.4.5 Creating a PhotoGallery control......Page 319
8.5 Summary......Page 325
Building Ajax-enabled controls......Page 326
9.1.1 Script descriptor hierarchy......Page 327
9.1.2 Describing a behavior......Page 329
9.1.3 Describing a control......Page 331
9.2 Introduction to Ajax-enabled controls......Page 333
9.2.1 How Ajax-enabled controls work......Page 334
9.2.2 Extenders and script controls......Page 335
9.3.1 The IExtenderControl interface......Page 338
9.3.2 Extender registration......Page 339
9.3.3 An extender for FormattingBehavior......Page 340
9.3.4 Using an extender......Page 343
9.4.1 The IScriptControl interface......Page 346
9.4.2 Script control registration......Page 347
9.4.4 Adding Ajax to the ASP.NET Login control......Page 349
9.4.5 Using a script control......Page 355
9.5 Summary......Page 357
Developing with the Ajax Control Toolkit......Page 359
10.1 A world of extenders......Page 360
10.1.1 The auto-complete extender......Page 361
10.1.3 The BehaviorID property......Page 367
10.2.1 The Toolkit’s base classes......Page 370
10.2.2 A metadata-driven API......Page 372
10.2.3 Building Toolkit extenders: the TextChanged extender......Page 374
10.2.4 Support for Visual Studio Designer......Page 382
10.3.1 Toolkit animation framework......Page 384
10.3.2 Animation basics......Page 386
10.3.3 Using the AnimationExtender......Page 387
10.3.4 The UpdatePanelAnimation extender......Page 391
10.3.5 JSON and animations: adding transitions to the PhotoGallery control......Page 392
10.4 Summary......Page 396
ASP.NET AJAX Futures......Page 397
XML Script......Page 398
11.1 XML Script basics......Page 399
11.1.1 Hello XML Script!......Page 400
11.1.2 Controls and XML Script......Page 403
11.1.3 From XML Script to JavaScript......Page 407
11.1.4 Type descriptors......Page 408
11.2 Actions......Page 411
11.2.1 SetPropertyAction......Page 412
11.2.3 InvokeMethodAction......Page 414
11.2.4 Custom actions......Page 419
11.3.1 A simple binding......Page 423
11.3.2 Binding direction......Page 425
11.3.3 Target and data path......Page 426
11.3.4 Bindings as components......Page 427
11.3.5 Transformers......Page 429
11.3.6 Playing with transformers......Page 430
11.3.7 Custom transformers......Page 433
11.4 Summary......Page 434
Dragging and dropping......Page 435
12.1 The drag-and-drop engine......Page 436
12.1.1 How the engine works......Page 437
12.1.2 A simple scenario for drag and drop......Page 440
12.1.3 Creating a draggable item......Page 441
12.1.4 The startDragDrop method......Page 443
12.1.5 The IDragSource interface......Page 444
12.1.6 Creating a drop target......Page 447
12.1.7 The IDropTarget interface......Page 448
12.1.8 Putting together the pieces......Page 451
12.2 A drag-and-drop shopping cart......Page 452
12.2.1 Server-side design......Page 454
12.2.2 Client-side design......Page 456
12.2.3 The ShoppingCart control......Page 457
12.2.4 The BooksCatalog control......Page 460
12.2.5 Piecing it together......Page 463
12.3 Summary......Page 465
Mastering ASP.NET AJAX......Page 466
Implementing common Ajax patterns......Page 467
13.1 Script versioning......Page 468
13.1.1 Getting informative stack traces......Page 469
13.1.2 XML comments in JavaScript code......Page 471
13.1.3 Validating function parameters......Page 473
13.1.4 Parameter validation in production code......Page 476
13.1.5 Compressing and crunching script files......Page 478
13.2 Helpers, help me help you!......Page 479
13.2.1 Automating the declaration of properties......Page 480
13.2.2 Automating the creation of events......Page 482
13.3 Logical navigation and unique URLs......Page 485
13.3.1 Logical navigation......Page 486
13.3.2 Unique URLs......Page 492
13.4.1 Setting up the Web Service......Page 494
13.4.2 The ListView control......Page 497
13.5 Declarative widgets......Page 500
13.5.1 The drag-drop list......Page 501
13.5.2 Widgets and XML Script......Page 503
13.6 Summary......Page 508
Appendices......Page 509
appendix A :Installing ASP.NET AJAX......Page 510
A.1 Downloading and installing ASP.NET AJAX......Page 511
A.1.2 Installing the ASP.NET Futures CTP......Page 514
A.2 Installing the Ajax Control Toolkit......Page 516
A.2.2 Using the Ajax Control Toolkit controls......Page 518
A.2.3 Interacting with CodePlex......Page 519
A.3 Installing the AdventureWorks database......Page 520
appendix B :Tools for debugging Ajax applications......Page 522
B.1 Using Firebug for Firefox......Page 523
B.1.1 Installing Firebug......Page 524
B.1.2 Quick Overview of Firebug......Page 525
B.2.2 Launching Web Developer Helper......Page 529
B.2.3 Inspecting HTTP traffic......Page 530
B.2.4 Script debugging and tracing......Page 532
B.2.5 Page and ASP.NET diagnostics......Page 534
B.3 Debugging HTTP with Fiddler......Page 535
B.4.1 Enabling script debugging in Internet Explorer......Page 539
B.4.2 Setting breakpoints......Page 540
B.4.3 Other ways to break into the debugger......Page 542
Resources......Page 544
index......Page 546