Building Interactive User Interfaces with Microsoft ASP.NET AJAX: A Look at JSON Serialization

Posted by: Headlines, on 08 Apr 2009 | View original | Bookmarked: 0 time(s)

Web applications commonly exchange information between the client (the browser) and the server (the ASP.NET application). In traditional web applications, this communication is usually insinuated when the visitor submits a form. This prompts the browser to re-request the page, sending the values of the form's inputs through the HTTP POST header. The server then renders the page and returns the entire page's markup, which is then redisplayed. AJAX-enabled web applications streamline this process. Instead of synchronous, bulky postbacks, AJAX-enabled applications use JavaScript to asynchronously communicate with the web server, transmitting only the necessary data and intelligently updating only the part of the screen whose contents have been modified (rather than redrawing the entire page, as with a full page postback).

Transmitting information over the Internet requires the sender to serialize it into some string-based format prior to sending it, and the receiver to deserialize it back into an object state that it can work with. For instance, if the client wants to send an array of integers to the server it must convert that array from its in-memory representation into a string, so that it can be transmitted across the network. Likewise, upon receiving the request, the receiver must turn that string representation of an array of integers back into an array of integers, so that it can use it programmatically.

XML was designed to serialize complex data into a string-based format, and early AJAX frameworks used XML as the serialization format. However, modern AJAX implementations use an alternate serialization format known as JavaScript Object Notation, or JSON. Like XML, JSON is an open, text-based serialization format, that is both human-readable and platform independent. It differs from XML in three important ways: it is much simpler to understand and implement than XML; it is less verbose, resulting in a slimmer payload; and, most importantly, data serialized in JSON can intuitively be parsed by JavaScript. In other words, working with data formatted in JSON in JavaScript involves one line of code - there's no need for a separate deserialization library or custom code to parse a message.

This article provides an overview of JSON's rules and illustrates how it is used in AJAX-enabled web applications. We'll also look at using the Microsoft ASP.NET AJAX framework's JavaScriptSerializer class, which facilitates serializing and deserializing JSON-formatted messages on the client in JavaScript or in C# or Visual Basic code on the server. Read on to learn more!
Read More >

Category: Ajax | Other Posts: View all posts by this blogger | Report as irrelevant | View bloggers stats | Views: 1992 | Hits: 54

Similar Posts

  • Unit Testing - Do Repeat Yourself more
  • Update to Logging in to DotNetNuke from a Silverlight Application with RIA Authentication more
  • Ajax survey 2009: jQuery and MS Ajax are almost tied more
  • Native JSON Parsing: What does it mean? more
  • Don't be afraid of complex constraints more
  • Periodically Updating the Screen and Web Page Title with ASP.NET AJAX more
  • C# 4.0, Dynamic Programming and JSON more
  • Simplicity is key to successful unit testing - Part 2 more
  • DataTable JSON Serialization in JSON.NET and JavaScriptSerializer more
  • SQL Server Reporting Services Subscriptions with custom security more

News Categories

.NET | Agile | Ajax | Architecture | ASP.NET | BizTalk | C# | Certification | Data | DataGrid | DataSet | Debugger | DotNetNuke | Events | GridView | IIS | Indigo | JavaScript | Mobile | Mono | Patterns and Practices | Performance | Podcast | Refactor | Regex | Security | Sharepoint | Silverlight | Smart Client Applications | Software | SQL | VB.NET | Visual Studio | W3 | WCF | WinFx | WPF | WSE | XAML | XLinq | XML | XSD