this print for content only—size & color not accurate spine = 0.924" 488 page count
BOOKS FOR PROFESSIONALS BY PROFESSIONALS
®
Pro Ajax and the .NET 2.0 Platform
Dear Reader,
Thanks to the folks at Google, Ajax technology has become a force to be reckoned
with. It is a technology that is here and now, just waiting for developers to
implement it. Google Maps, Google Suggest, and Flickr are just a few of the sites
out there that have moved Ajax into the mainstream. More will come as the
technology becomes easier to implement. This book will examine not only Ajax
technology, but also XmlHttpRequest processes, putting theory into code with
samples that duplicate many of the technologies utilized by the aforementioned
cutting-edge websites.
Fortunately for C# developers, we have Ajax options right now in the form of
some newly released class libraries that open the Ajax door to the .NET
Framework. The majority of the code in this book centers on a third-party
library called Anthem, written by Jason Diamond. One of the benefits of using
this library is that you’ll also have backwards compatibility to Visual Studio
2003, as a majority of the code in this book will work with .NET 1.1 or 2.0.
Having that range of opportunity makes Ajax development accessible to all.
You’ll also get an introductory look at Microsoft’s Atlas and how it holds up
against Ajax. You’ll have a chance to build an Atlas application as well and
decide for yourself whether Atlas is the right fit for your development work.
I’m confident that this book will help you get a firm grasp on the dynamic
tools that are available now. You’ll be ready for next-generation web develop-
ment in a surprisingly short amount of time.
Dan Woolston
US $49.99
Shelve in
Web Development
User level:
THE APRESS ROADMAP
Pro Ajax and the
.NET 2.0 Platform
Illustrated C#
Foundations of Atlas:
Rapid Ajax Development
with ASP.NET 2.0
Foundations of Ajax
Pro C# 2005 and the .NET
2.0 Platform, Third Edition
Ajax Patterns
and Best Practices
Pro
Daniel Woolston
Pro Ajax and the
.NET 2.0 Platform
6706fmfinal.qxd 6/20/06 3:40 PM Page i
P
ro Ajax and the .NET 2.0 Platform
Copyright © 2006 by Daniel Woolston
All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means,
electronic or mechanical, including photocopying, recording, or by any information storage or retrieval
system, without the prior written permission of the copyright owner and the publisher.
ISBN-13 (pbk): 978-1-59059-670-8
ISBN-10 (pbk): 1-59059-670-6
Printed and bound in the United States of America 9 8 7 6 5 4 3 2 1
Trademarked names may appear in this book. Rather than use a trademark symbol with every occurrence
of a trademarked name, we use the names only in an editorial fashion and to the benefit of the trademark
owner, with no intention of infringement of the trademark.
Lead Editor: Matthew Moodie
that you have had throughout the years.
Thank you.
6706fmfinal.qxd 6/20/06 3:40 PM Page iii
Contents at a Glance
About the Author . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xv
About the Technical Reviewer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvi
Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix
PART 1
■ ■ ■
Ajax Concepts
■CHAPTER 1 History and Revival of Ajax. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
■CHAPTER 2 Introducing JavaScript. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
■CHAPTER 3 The XmlHttpRequest Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
■CHAPTER 4 N-Tier and Ajax. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
PART 2
■ ■ ■
Ajax Components
■CHAPTER 5 Rich Inter
net Applications
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
■CHAPTER 6 CSS and the DOM. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
■CHAPTER 7 Ajax Frameworks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
PART 3
■ ■ ■
Concept to Code
■CHAPTER 8 Understanding the Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
■CHAPTER 9 Ajax and Web Services. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
■CHAPTER 10 Tagging with Ajax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207
■CHAPTER 11 Cloning Google Suggest. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
■CHAPTER 1 History and Revival of Ajax. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
The Age of Discovery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1970. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1975. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1979. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1991. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
The
Age of Implementa
tion
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1993. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1994. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
The Age of War . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1995. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1996. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1997. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1998. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1999. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
The Age of Transition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2000. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2001. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
The Age of Experimentation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2002–2004. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
9
2005. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Summar
y
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
14
vii
LOADPOSTBACKDA
T
A
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
42
LOAD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
RAISEPOSTBACKEVENT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
43
SA
VEVIEWST
ATE
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
43
Render. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
Asynchronous Resource Retrieval . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
Header Requests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
Retrieving XML Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
Introducing JSON. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
Summar
y
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
64
■CONTENTSviii
6706fmfinal.qxd 6/20/06 3:40 PM Page viii
■CHAPTER 4 N-Tier and Ajax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
What Is N-Tier? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
Application Layer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
Business Layer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
Data Layer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
Data Store . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
CSS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
Style Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
Inline Style. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
Script Blocks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
CSS Selectors. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
CSS Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
CSS Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
Site-wide Style Access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
CSS Element Alignment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
Positioning. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
Element Visibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118
Document Object Model. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
How the DOM Came to Be . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
Definition of the DOM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
Working with the DOM Node . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122
Modifying Style Elements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
Debugging DOM issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
Using the Technology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
Default.aspx . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128
dataFetch.aspx.cs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
Summar
y
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
■CHAPTER 7 Ajax Frameworks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
Non NET and Cross-Platform. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
Ruby on Rails . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
Dojo Toolkit. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
SAJAX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
xajax. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
139
■CHAPTER 9 Ajax and Web Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
So What Is a Web Service? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
SOAP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
Affecting Ajax. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
Creating the Web Service. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
Building the Ajax Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
Accessing with XmlHttpRequest . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195
Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206
■CHAPTER 10 Tagging with Ajax. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207
Creating the Da
tabase
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209
The Tagging Application. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210
HTML Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211
C# Code. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215
Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225
■CHAPTER 11 Cloning Google Suggest . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227
Introducing Google Suggest. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
227
Implementing Google Suggest . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228
SearchP
a
ge.aspx
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
228
SearchP
a
ge.aspx.cs
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
231
Yahoo Response Elements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289
Image Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290
Item Elements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291
Using the Feed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292
Summar
y
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298
■CHAPTER 14 Ajax and Web Parts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299
Web Parts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 302
Ajax and Web Parts Sample Application . . . . . . . . . . . . . . . . . . . . . . . . . . . 303
ucCustomerLocator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 318
Tracking ZIP Codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322
Y
ahoo! Sta
tic Ma
ps
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
322
Building the Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325
Summar
y
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
326
■CONTENTSxii
6706fmfinal.qxd 6/20/06 3:40 PM Page xii
PART 4
■ ■ ■
Security and Performance
■CHAPTER 15 Ajax and ASP.NET Security. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 329
Ajax As a Secure Platform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 329
Edit and Continue. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
374
Using
Visualizers
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
375
Enhanced DataTips . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 377
Just My Code Debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 378
Third-party Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 378
Fiddler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 378
Microsoft’s Developer Toolbar. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 382
Summar
y
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
389
■CONTENTS
xiii
6706fmfinal.qxd 6/20/06 3:40 PM Page xiii
■CHAPTER 18 Ajax and Site Testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 391
Stress Test Tools. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 391
Creating the Application to Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 393
Using the Test Suite . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 396
Testing the Postback Page. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 396
Testing the Ajax Page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 401
Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 408
■CHAPTER 19 Ajax Usability. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 409
The Back Button . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 409
Ajax Menus. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 412
Ajax Type-Aheads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 412
Bookmarking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 414
pplication
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
429
The Atlas Version . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 441
AutoCompleteBehavior Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 445
Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 451
■INDEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
453
■CONTENTSxiv
6706fmfinal.qxd 6/20/06 3:40 PM Page xiv
fa938d55a4ad028892b226aef3fbf3dd
About the Author
■DANIEL WOOLSTON is a software engineer from the Grand Rapids, Michigan
area. Daniel’s software journey began in the late 1980s with the infamous
Sinclair ZX80. His current ambitions involve developing next-generation
.NET web applications utilizing the latest technologies and beyond. His
work efforts have branched from Fortune 500 enterprise application devel-
opment to pattern-driven project implementations on various corporate
levels. He has years of experience in designing and distributing JavaScript/
.NET components as well as numerous VB/VB .NET/C# development projects. When he’s not
cutting through code, he can usually be found in his makeshift mad-scientist basement lab
building robots, one of which was recently featured in a national robotics magazine.
xv
6706fmfinal.qxd 6/20/06 3:40 PM Page xv
About the Technical Reviewer
■NICK MCCOLLUM has over 18 years of experience designing and developing
enterprise applications on a variety of platforms. He is a principal consult-
ant for NuSoft Solutions, Inc., and for the past year has been the architect
and lead developer for Spout (www.spout.com). In addition to this publica-
tion, Nick has acted as a technical reviewer for
Lastly, I must offer up an endless supply of appreciation and respect to Michelle, Aymee,
and Michael Woolston. You have graciously given up a daddy and a husband for most of the
year so that I could accomplish a long-standing goal. And now that I’ve finished the book,
I
find that the greatest achievement was not the book itself, but the encouragement and
patience that you’ve given me for the last few months. Thank you so much!
xvii
6706fmfinal.qxd 6/20/06 3:40 PM Page xvii
6706fmfinal.qxd 6/20/06 3:40 PM Page xviii
Introduction
It’s been well over a year since I first began working with the team over at Spout (www.spout.
com
). In the course of that year, I’ve been professionally challenged by the sheer amount of
cutting-edge work that I have been asked to develop. I can still remember Brian Anderson
(NuSoft Solutions) coming to Nick McCollum and me with a few sheets of paper detailing a
new third-party web tool that we should take a look at. The design documents were a brief
listing of the sample code for Ajax.NET by Michael Schwarz. Not only had Michael built an
awesome library, but he had done so for free. Nick and I embraced the library without hesi-
tation. Admittedly, we overused the library at first. We Ajax’d the site to its fullest extent. Need
a user control built? Use Ajax! At least that is how it felt at first. We were truly excited (and remain
so today) about the possibilities of Ajax and where it would lead our project. I want to share
this excitement with you.
An Overview of This Book
I want to deal with the world of Ajax to its finest detail. In order to do that, we’ll need to discuss
where Ajax came from, what it comprises, and how we can implement modern third-party Ajax
libraries. The technology is ever changing, and I encourage you to visit the various author sites
found throughout the book so that you may stay up to date. Many of the chapters have real-
world application, and you may find yourself coming back to the book as a reference for future
projects. I would also encourage you to blog about your work and the obstacles you overcome.
Had Peter Bromberg (
• Chapters 15 through 19 will deal exclusively with the usage aspect of Ajax. How we
design, debug, monitor, and scale the projects that we build will be the key concepts
covered.
• Chapter 20 will wrap up the book with a detailed look at Microsoft’s Atlas. We’ll build a few
applications to demonstrate some of the central functionality that the library provides.
Ajax Requirements
I’d like to discuss a few of the various requirements that Ajax may impose upon your develop-
ment realm.
Browser Support
A key component of Ajax technology is the XmlHttpRequest object, and without it any form of
communication with the server would be nearly impossible. It wasn’t until Internet Explorer
version 5 was released that the XmlHttpRequest capability was available to developers. Unfor-
tunately, it was only functional within the IE browser. However, more and more companies/
open source communities are embracing the object, and subsequently the XmlHttpRequest
object has become widely compatible with modern browsers:
• Internet Explorer 5.0 and above
• Firefox 1.0 and above
•
S
afari 1.2 and above
• Opera 7.6 and above
• Konqueror
•
N
etscape 7.0 and abo
v
e
JavaScript Enabled
One of the criticisms surrounding Ajax.NET technology is that unilateral support may be
interrupted by those users who have disabled JavaScript or ActiveX functionality.
.NET. I won’t editorialize the ongoing debate on which is better. I will say that I was in total
agreement with something that Rocky Lhotka said at a .NET users group meeting: “If you’re not
learning and using both, then you’re selling yourself short.” Well put, Rocky!
Ajax.NET Library
As Ajax grows in popularity, so does the volume of Ajax.NET interface libraries available across
the web
. Essentially these libraries take the complexity out of utilizing XmlHttpRequest and
r
ender simple methods for client- and ser
v
er
-side usage
.
You could, of course, skip the imple-
mentation of an Ajax.NET library and code the XmlHttpRequest processes yourself. However,
as many dev
elopers have said, “Why reinvent the wheel?”
■INTRODUCTION
xxi
6706fmfinal.qxd 6/20/06 3:40 PM Page xxi
There are many libraries out there, as I’ve said before, but two stand out from the rest:
•
Michael Schwarz’s Ajax.NET Professional ( A popu-
l
ar and effective toolset. It’s updated and supported by Michael and a newly established
Google group (
Keep in mind that this
library makes use of HTTPHandlers and for some that could create some issues. I’ve
had the opportunity to use this on a work-related project (
www.spout.com) and was
form, marries CSS, HTML, JavaScript, and the .NET Framework to produce dynamic web
content. However, this collaborative effort was not born in a day. It may surprise many to
find out how this “new” technology has surfaced as a powerhouse of dynamic web con-
tent. Before we jump into coding and conventions, let’s take a look at the relatively short
history of web development.
PART 1
■ ■ ■
6706ch01final.qxd 6/20/06 2:48 PM Page 1
6706ch01final.qxd 6/20/06 2:48 PM Page 2