You are previewing Microsoft AJAX Library Essentials: Client-side ASP.NET AJAX 1.0 Explained: A practical tutorial to using Microsoft AJAX Library to enhance the user experience of your ASP.NET Web Applications.
O'Reilly logo
Microsoft AJAX Library Essentials: Client-side ASP.NET AJAX 1.0 Explained: A practical tutorial to using Microsoft AJAX Library to enhance the user experience of your ASP.NET Web Applications

Book Description

A practical tutorial to using Microsoft AJAX to enhance the user experience of your ASP.NET web applications covering the most up to date versions of the AJAX tools.

Microsoft AJAX Library Essentials is a practical reference for the client-side library of the ASP.NET AJAX Framework 1.0, and a tutorial for the underlying technologies and techniques required to use the library at its full potential. The main goal of this book is to get you comfortable with the Microsoft AJAX Library, a huge set of functions that can be used for developing powerful client-side functionality.

Beginning with a hands-on tour of the basic technologies associated with AJAX, JavaScript, XMLHttpRequest, JSON, and the DOM, you'll move on to a crash course in the Microsoft AJAX tools. You will learn, through numerous step-by-step exercises, how to create basic AJAX applications, how the object-based programming model of JavaScript works, and how Microsoft AJAX Library extends this model. You'll understand the architecture of the Microsoft AJAX components, how they all fit together, and exactly what they can do for you. Then you will learn how to use the Microsoft AJAX Library in your web projects, and a detailed case study will walk you through creating your own customized client components.

At every stage of your journey, you'll be able to try out examples to illuminate the theory, and consolidate your understanding. In addition to learning about the client and server controls, you'll also see how to handle errors and debug your AJAX applications.

To complement your new found skills, the book ends with a visual reference of the Microsoft AJAX Library namespaces and classes, including diagrams and quick explanations for all the classes mentioned in the book, providing an invaluable reference you will turn to again and again.

  • A rapid and practical guide to including AJAX features in your .NET applications

  • Learn practical development strategies and techniques

  • Go through a case study that demonstrates the theory you learned throughout the book.

This book has been written for ASP.NET developers entering the world of the ASP.NET AJAX Framework, and for existing ASP.NET AJAX developers looking for a more detailed tutorial on the client-side of the framework: the Microsoft AJAX Library.

Table of Contents

  1. Copyright
  2. Credits
  3. About the Authors
  4. About the Reviewers
  5. Preface
    1. What This Book Covers
    2. What You Need for This Book
    3. Who is This Book for
    4. Conventions
    5. Reader Feedback
    6. Customer Support
    7. Downloading the Example Code for the Book
    8. Errata
    9. Questions
  6. 1. AJAX and ASP.NET
    1. The Big Picture
      1. AJAX and Web 2.0
    2. Building Websites Since 1990
      1. HTTP and HTML
      2. ASP.NET and Other Server-Side Technologies
      3. JavaScript and Other Client-Side Technologies
      4. What’s Missing?
    3. The World of AJAX
      1. What is AJAX Made Of?
      2. Uses and Misuses of AJAX
      3. Introducing ASP.NET AJAX
      4. Resources and Tools
    4. Setting Up Your Environment
      1. Installing IIS
      2. Installing Visual Web Developer
      3. Creating a Folder for Your Project
        1. Preparing the Atlas Application in Windows Vista
        2. Preparing the Atlas Web Application in Windows XP
    5. Hello World!
      1. Time for Action—Quickstart AJAX
      2. What Just Happened?
    6. Summary
  7. 2. AJAX Foundations
    1. JavaScript and the Document Object Model
      1. Time for Action—Playing with JavaScript and the DOM
      2. What Just Happened
    2. JavaScript Events and the DOM
      1. Time for Action—Using JavaScript Events and the DOM
      2. What Just Happened?
    3. Even More DOM
      1. Time for Action—Even More DOM
      2. What Just Happened?
    4. JavaScript, DOM, and CSS
      1. Time for Action—Working with CSS and JavaScript
      2. What Just Happened?
    5. The XMLHttpRequest Object
      1. Creating the XMLHttpRequest Object
      2. Initiating Server Requests
      3. Handling the Server Response
        1. Time for Action—Making Asynchronous Calls with XMLHttpRequest
        2. What Just Happened?
    6. Summary
  8. 3. Object-Oriented JavaScript
    1. Concepts of Object-Oriented Programming
      1. Objects and Classes
      2. Encapsulation
      3. Inheritance
      4. Polymorphism
    2. Object-Oriented JavaScript
      1. JavaScript Functions
        1. Functions as Variables
        2. Anonymous Functions
        3. Inner Functions and JavaScript Closures
      2. JavaScript Classes
        1. Class Diagrams
        2. C# and JavaScript Classes
        3. Referencing External Functions
        4. Thinking of Objects as Associative Arrays
        5. Creating Object Members on the Fly
        6. Private Members
        7. Prototypes
      3. The JavaScript Execution Context
        1. var x, this.x, and x
        2. Using the Right Context
      4. Inheritance using Closures and Prototypes
        1. Inheritance Using Closures
        2. Inheritance Using Prototyping
    3. Introducing JSON
    4. Summary
  9. 4. Introducing the Microsoft AJAX Library
    1. Microsoft AJAX Library Components
    2. Asynchronous Communication
      1. Client Asynchronous Communication
      2. Server Asynchronous Communication
    3. Working with WebRequest
      1. Time for Action—WebRequest
      2. What Just Happened?
    4. More WebRequests
      1. Time for Action—More WebRequest
      2. What Just Happened?
    5. Summary
  10. 5. OOP with the Microsoft AJAX Library
    1. The New Features
    2. JavaScript Base Classes Extensions
      1. Time for Action: Bubble Sort and Base Classes Extensions
      2. What Just Happened?
    3. Classes in Microsoft AJAX Library
      1. The Type, Namespaces, and Events
        1. Time for Action—Creating and Using the Person Class
        2. What Just Happened?
      2. Inheritance
        1. Time for Action—Implementing Inheritance using Microsoft AJAX Library
        2. What Just Happened?
      3. Enumerations
      4. Interfaces
        1. Time for action—Inheritance and Interfaces
        2. What Just Happened?
      5. OOP Recommendations
    4. Summary
  11. 6. Creating Client Components
    1. DOM Elements and Events
    2. Components, Behaviors, and Controls
      1. Creating Components
      2. Disposing of Components
      3. Sys.Application and Client Page Life-Cycle Events
        1. The init Event
        2. The load Event
        3. The pageLoad() Method
        4. The pageUnload() Method
        5. The unload Event
      4. Behaviors
      5. Controls
      6. Quicksteps for Creating Custom Client Components
    3. Summary
  12. 7. Case Study: Timer and EnhancedTextBox
    1. The Timer Component
    2. The EnhancedTextBox Behavior
    3. Creating Timer and EnhancedTextBox
      1. Time for Action—Creating Custom Client Components
      2. What Just Happened?
    4. Using the Components
    5. Summary
  13. 8. Debugging Tools and Techniques
    1. AJAX Debugging Overview
    2. Debugging and Tracing with Microsoft AJAX Library
      1. MicrosoftAjax.debug.js
      2. Anonymous Functions vs. Pseudo-Named Functions
      3. Parameters Validation
    3. Debugging in Internet Explorer
      1. Web Development Helper
      2. Internet Explorer Developer Toolbar
      3. Other tools
    4. Debugging in Firefox
      1. Firebug
      2. Venkman JavaScript Debugger
      3. Web Developer
    5. Fiddler
    6. Testing
    7. Summary
  14. A. Microsoft AJAX Library Reference
    1. Conventions
    2. Function Class
      1. emptyMethod() Method
      2. _validateParams() Method
        1. Parameters
        2. Returns
        3. Remarks
        4. Example
      3. createDelegate() Method
        1. Parameters
        2. Returns
        3. Remarks
        4. Example
      4. createCallback() Method
        1. Parameters
        2. Returns
        3. Remarks
        4. Example
      5. Type Class
    3. JavaScript Base Type Extensions
      1. Array Class
      2. Boolean Class
      3. Date Class
      4. Error Class
        1. create() Method
          1. Parameters
          2. Returns
          3. Remarks
          4. Example
      5. Number Class
      6. Object Class
      7. RegExp Class
      8. String Class
    4. Sys Namespace
      1. Sys.Application Class
      2. Sys.ApplicationLoadEventArgs Class
      3. Sys.Browser Class
      4. Sys.CancelEventArgs Class
      5. Sys.Component Class
      6. Sys.CultureInfo Class
      7. Sys.Debug Class
      8. Sys.EventArgs Class
      9. Sys.EventHandlerList Class
      10. Sys.IContainer Interface
      11. Sys.IDisposable Interface
      12. Sys.INotifyDisposing Interface
      13. Sys.INotifyPropertyChange Interface
      14. Sys.PropertyChangedEventArgs Class
      15. Sys.ScriptLoader Class
      16. Sys.ScriptLoaderTask Class
      17. Sys.StringBuilder Class
    5. Sys.UI Namespace
      1. Sys.UI.Behavior Class
      2. Sys.UI.Bounds Class
      3. Sys.UI.Control Class
      4. Sys.UI.DomElement Class
        1. getElementById() Method ($get)
          1. Parameters
          2. Remarks
          3. Example
        2. addCssClass() Method
          1. Parameters
          2. Example
        3. containsCssClass() Method
          1. Parameters
          2. Returns
          3. Example
        4. removeCssClass() Method
          1. Parameters
          2. Example
        5. toggleCssClass() Method
          1. Parameters
          2. Example
        6. getLocation() Method
          1. Parameters
          2. Returns
        7. getBounds() Method
          1. Parameters
          2. Returns
          3. Remarks
          4. Example
        8. setLocation() Method
          1. Parameters
          2. Remarks
          3. Example
      5. Sys.UI.DomEvent Class
      6. Sys.UI.Key Class
        1. addHandler() Method ($addHandler)
          1. Parameters
          2. Remarks
          3. Example
        2. addHandlers() Method ($addHandlers)
          1. Parameters
          2. Remarks
          3. Example
        3. clearHandlers() Method ($clearHandlers)
          1. Parameters
          2. Remarks
          3. Example
        4. preventDefault() Method
          1. Example
        5. removeHandler() Method
          1. Parameters
          2. Example
        6. stopPropagation() Method
          1. Example
      7. Sys.UI.MouseButton Enumeration
      8. Sys.UI.Point Class
      9. Sys.UI.VisibilityMode Enumeration
    6. Sys.Net Namespace
      1. Sys.Net.NetworkRequestEventArgs Class
      2. Sys.Net.WebRequest Class
      3. Sys.Net.WebRequestExecutor Class
      4. Sys.Net.WebRequestManager Class
      5. Sys.Net.XmlHttpExecutor Class
    7. Sys.Serialization Namespace
      1. Sys.Serialization.JavaScriptSerializer Class
        1. serialize() Method
          1. Parameters
          2. Returns
          3. Remarks
        2. deserialize() Method
          1. Parameters
          2. Returns
          3. Remarks