Book Image

Microsoft AJAX Library Essentials: Client-side ASP.NET AJAX 1.0 Explained

Book Image

Microsoft AJAX Library Essentials: Client-side ASP.NET AJAX 1.0 Explained

Overview of this book

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.
Table of Contents (14 chapters)
Copyright
Credits
About the Authors
About the Reviewers
Preface

Sys.Serialization Namespace


This namespace contains a single class: Sys.Serialization.JavaScriptSerializer.

Sys.Serialization.JavaScriptSerializer Class

Sys.Serialization.JavaScriptSerializer (Figure A-48) provides two static methods for serializing types into JSON formatted data strings and for deserializing JSON formatted data strings into JavaScript types.

Figure A-48 Sys.Serialization.JavaScriptSerializer

serialize() Method

Static method that serializes a JavaScript object into a string representation of the corresponding JSON object.

Parameters

obj – the JavaScript object to be serialized.

Returns

The method returns the string representation of the JSON object representing the JavaScript object.

Remarks

Date objects are serialized as \/Date(milliseconds from the 1st January 1970)\/.

Properties that start with $ are skipped.

Non-finite numbers are not serialized. The isFinite() JavaScript function is used to determine whether a number is finite or not.

Special characters are escaped using a \ and Unicode characters by using \u00.

deserialize() Method

Static method that deserializes a JSON object and returns a JavaScript object.

Parameters

data – the string representation of the JSON object to be deserialized.

Returns

The method returns the JavaScript object corresponding to the JSON object.

Remarks

Date objects are serialized as \/Date(milliseconds from the 1st January 1970)\/ so that they can be correctly deserialized.

The JavaScript object is constructed by calling eval() on the JSON string.