6471fmfinal.qxd 5/10/06 11:23 PM Page i Foundations of Atlas Rapid Ajax Development with ASP.NET 2.0 Laurence Moroney 6471fmfinal.qxd 5/10/06 11:23 PM Page ii Foundations of Atlas: Rapid Ajax Development with ASP.NET 2.0 Copyright © 2006 by Laurence Moroney 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-647-0 ISBN-10 (pbk): 1-59059-647-1 Printed and bound in the United States of America 9 8 7 6 5 4 3 21 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: Ewan Buckingham Technical Reviewer: Keith Smith Editorial Board: Steve Anglin, Ewan Buckingham, Gary Cornell, Jason Gilmore, Jonathan Gennick, Jonathan Hassell, James Huddleston, Chris Mills, Matthew Moodie, Dominic Shakeshaft, Jim Sumser, Keir Thomas, Matt Wade Project Manager: Kylie Johnston Copy Edit Manager: Nicole LeClerc CopyEditor:Kim Wimpsett Assistant Production Director: Kari Brooks-Copony Production Editor: Laura Esterman Compositor: Linda Weidemann, Wolf Creek Press Proofreader: Nancy Sixsmith Indexer: Michael Brinkman Artist: Kinetic Publishing Services,LLC Cover Designer: Kurt Krames Manufacturing Director: Tom Debolski Distributed to the book trade worldwide by Springer-Verlag New York, Inc., 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax 201-348-4505, e-mail [email protected], or visit http://www.springeronline.com. For information on translations, please contact Apress directly at 2560 Ninth Street, Suite 219, Berkeley, CA 94710. Phone 510-549-5930, fax 510-549-5939, e-mail [email protected],or visit http://www.apress.com. The information in this book is distributed on an “as is” basis, without warranty. Although every precau- tion has been taken in the preparation of this work, neither the author(s) nor Apress shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in this work. The source code for this book is available to readers at http://www.apress.comin the Source Code section. 6471fmfinal.qxd 5/10/06 11:23 PM Page iii This book is dedicated to my brother,Niall,all-round cool guy and great big brother,as well as provider of free accommodation whenever I visit Ireland;to his wife,Sandra,among the warmest and most loving people I have ever met;to his son,Sean,the local guitar god;and to his daughter,Aideen,the sweetest girl in Ireland. 6471fmfinal.qxd 5/10/06 11:23 PM Page iv 6471fmfinal.qxd 5/10/06 11:23 PM Page v Contents at a Glance Foreword........................................................................xiii About the Author .................................................................xv About the Technical Reviewer ......................................................xvi Acknowledgments ...............................................................xvii Introduction .....................................................................xix nCHAPTER 1 Introducing Ajax................................................1 nCHAPTER 2 Atlas:Taking Ajax to the Next Level ............................17 nCHAPTER 3 Atlas:Making Client-Side JavaScript Easier ....................33 nCHAPTER 4 Introducing Client Controls in Atlas.............................53 nCHAPTER 5 Using Client Controls in Atlas ..................................77 nCHAPTER 6 Introducing Server Controls in Atlas...........................125 nCHAPTER 7 Using Server Controls in Atlas.................................165 nCHAPTER 8 Data Binding in Atlas .........................................197 nCHAPTER 9 Using the AtlasUIGlitz Library .................................231 nCHAPTER 10 Mapping with Atlas...........................................249 nCHAPTER 11 Building a Sample Application with ASP.NET and Atlas...........269 nINDEX .......................................................................305 v 6471fmfinal.qxd 5/10/06 11:23 PM Page vi 6471fmfinal.qxd 5/10/06 11:23 PM Page vii Contents Foreword........................................................................xiii About the Author .................................................................xv About the Technical Reviewer ......................................................xvi Acknowledgments ...............................................................xvii Introduction .....................................................................xix nCHAPTER 1 Introducing Ajax .............................................1 Delving into the Historyof Web Application Technology................1 Thin Client Applications Arriving to Save the Day .....................8 Ajax Entering the Picture ..........................................9 Using the XMLHttpRequest Object.................................10 Using Visual Studio 2005.........................................12 Seeing a Simple Example in Action ................................12 Summary.......................................................15 nCHAPTER 2 Atlas: Taking Ajax to the Next Level.......................17 Introducing ASP.NET 2.0 Server Controls...........................17 Introducing the Atlas Architecture .................................22 Atlas Client Script Library....................................23 JavaScript Object Notation (JSON)............................24 Atlas Web User Interfaces ...................................24 Atlas Web UI Data Binding...................................25 Creating Atlas Components..................................28 Atlas Behaviors.............................................30 Summary.......................................................31 nCHAPTER 3 Atlas: Making Client-Side JavaScript Easier..............33 Using JavaScript in Atlas.........................................33 Creating Your First Atlas Application ..........................33 Adding a Custom JavaScript Class............................35 Using the Atlas Script Manager to Deliver Your Custom Class ....37 Coding and Running the Application...........................41 vii 6471fmfinal.qxd 5/10/06 11:23 PM Page viii viii nCONTENTS Using Namespaces in JavaScript..................................43 Using Inheritance in JavaScript....................................44 Implementing Interfaces in JavaScript .............................46 Accessing Server Resources from JavaScript .......................48 Summary.......................................................52 nCHAPTER 4 Introducing Client Controls in Atlas .......................53 Seeing a Basic Example in Action .................................53 Using the Atlas UI Client Controls..................................56 The UI Control..............................................56 The Label Control...........................................57 The Button Control..........................................59 The InputControl Control.....................................60 The TextBox Control ........................................62 The Image Control..........................................63 The HyperLink Control.......................................64 The CheckBox Control.......................................66 The Select Control..........................................67 Using Atlas Script ...............................................69 Summary.......................................................76 nCHAPTER 5 Using Client Controls in Atlas..............................77 Manipulating Controls Using CSS..................................77 Using JavaScript ...........................................78 Using Atlas Script...........................................83 Manipulating Controls Directly ....................................87 Using JavaScript to Manipulate Controls Directly ...............87 Using Atlas Script to Manipulate Controls Directly...............89 Data Binding with a Transform....................................92 Using Atlas Script...........................................92 Using JavaScript ...........................................94 Data Binding with a Custom Transform.............................95 Performing JavaScript Custom Binding............................100 Performing Basic Text Validation—Required Fields.................103 Performing Basic Text Validation—Checking for Types and Ranges...106 Using the Click Behavior ........................................111 Using the Mouse Hover Behavior.................................113 6471fmfinal.qxd 5/10/06 11:23 PM Page ix nCONTENTS ix Using the Pop-up Behavior When You Hover Over an Element........116 Implementing Drag-and-Drop Behaviors ..........................119 Summary......................................................123 nCHAPTER 6 Introducing Server Controls in Atlas......................125 Adding the Atlas Server Controls to Visual Studio 2005..............125 Creating an Atlas Web Site..................................125 Adding the Server Controls to the Toolbox ....................126 Introducing the ScriptManager Control............................129 Using the ScriptManager Designer Interface ..................129 Programming with the Script Manager .......................130 Introducing the ScriptManagerProxy Control .......................138 Introducing the UpdatePanel Control..............................141 Using the UpdatePanel Designer.............................142 Programming with the UpdatePanel..........................144 Introducing the UpdateProgress Control...........................146 Introducing Control Extenders....................................147 Introducing the AutoCompleteExtender.......................147 Using the DragOverlayExtender..............................148 Introducing the ProfileScriptService Control........................152 Introducing the Timer Control....................................153 Introducing the Gadget Control...................................155 Summary......................................................163 nCHAPTER 7 Using Server Controls in Atlas ............................165 Using the UpdatePanel Control...................................165 Using a Task List Manager ......................................168 Using the Atlas Wiki Application..................................180 Getting Started with the Wiki Application .....................180 Running the Wiki Application................................182 Understanding the Login Asynchrony.........................184 Creating a Wiki User .......................................187 Understanding the Create Article Asynchrony .................191 Understanding the Table of Contents Asynchrony..............193 Summary .....................................................196
Description: