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

Chapter 1. AJAX and ASP.NET

“Computer, draw a robot!” said my young cousin to the first computer he had ever seen. (Since I had instructed it not to listen to strangers, the computer wasn’t receptive to this command.) If you’re like me, your first thought would be “how silly” or “how funny”—but this is a mistake. We’re being educated to accommodate computers, to compensate for the lack of ability of computers to understand humans, but in an ideal world that spoken command should have been enough to have the computer please my cousin.

This book doesn’t aim to teach you how to create software applications that intelligently interact with children—we’re still far from that point. However, we’ll help you make a small but important step in that direction. We’ll teach you how to use web development technologies available today—AJAX and ASP.NET AJAX in particular—to enhance web users’ experience of your web site, by creating more usable and friendly web interfaces. As far as this chapter is concerned, we’ll discuss the following topics:

  • The Big Picture.Here we’ll answer a question we’re often asked: “Why bother improving our applications’ user interfaces and features, when the existing ones perform satisfactorily?”

  • Building Websites Since 1990.What are the fundamental principles of the Web, and what are the important technologies that make it work? You probably know most of this, but we hope you’ll welcome this quick refresher.

  • The World of AJAX.As you will learn (if you don’t already know), AJAX is a powerful tool that you can use to improve your web interfaces. However, it’s important to understand when you should use it, and when you should probably not. We’ll also discuss the basic principles of AJAX, and refer to online resources and tools that can help you along the way.

  • Setting Up Your Environment.In this book you’ll find plenty of code—and you’ll probably be curious to execute it, and see it in action. We’ve taken care of that by including step-by-step instructions with every exercise. To avoid any potential problems following the exercises, in this section we walk you through the installation and configuration process for the software you need.

  • Hello World!After reading so much pure theory, and installing many software packages (and we all know how boring software installation can be), you’ll probably be eager to write some code, so at the end of this chapter, you’ll write your first AJAX application.

Let’s get started. We hope your journey through this book will be a pleasant and useful one!

The Big Picture

The story about Cristian’s 7-years old cousin—which happened back in 1990—is still relevant today, regarding the way people instinctively work with computers. The ability of technology to be user-friendly has evolved very much in the past years, but there’s still a long way until we have really intelligent computers that self-adapt to our needs. Until then, people need to learn how to work with computers—some to the extent that they end up loving a black screen with a tiny command prompt on it!

We will be very practical and concise in this book, but before getting back to your favorite mission—writing code—it’s worth taking a little step back, just to remember what we are doing and why we are doing it. We love technology to the sound made by each key stroke, so it’s very easy to forget that the very reason technology exists is to serve people and make their lives at home more entertaining, and at work more efficient.

The computer-working habits of many are driven by software with user interfaces that allow for intuitive (and enjoyable) human interaction. Not coincidentally, successful companies are typically one step ahead of their competition in offering their users simple and natural ways of achieving their goals. This probably explains the popularity of the mouse, of fancy features such as drag and drop, and of that simple text box that searches all the Web for you in just 0.1 seconds (or so it says).

Understanding the way people’s brains work would be the key to building the ultimate software application. While we’re far from that point, what we do understand is that end users need intuitive user interfaces; they don’t really care what operating system they’re running as long as the functionality they get is what they want. This is a very important detail to keep in mind, as programmers typically tend to think and speak in technical terms when interacting with end users. If you disagree, try to remember how many times you’ve said the word “database” when talking to a non-technical person.

The behavior of any computer software that interacts with humans is now even more important than it used to be, because nowadays the computer user base varies much more than in the past, when the users were technically sound as well. Now you need to display good looking reports to Cindy, the sales department manager, and you need to provide easy-to-use data entry forms to Dave, the sales person.

By observing people’s needs and habits while working with computer systems, the term software usability was born—referring to the art of meeting users’ interface expectations, understanding the nature of their work, and building software applications accordingly. AJAX in general, and the ASP.NET AJAX Framework in particular, are modern tools that web developers can use to develop user-friendly Web Applications. As with any other tool, however, they can be used improperly, complicating the user experience, neglecting users with disabilities, or lowering search engine performance.

This being a programming book, our strong focus will regard the technical aspects of Microsoft AJAX Library. However, as a responsible web developer, you should not lose sight of the complementary aspects that affect the success of a web application. If you haven’t already, we strongly recommend that you check at least some of these resources:

  • Don’t Make Me Think: A Common Sense Approach to Web Usability, second edition, by Steve Krug (New Riders Press, 2005)

  • Prioritizing Web Usability, by Jakob Nielsen and Hoa Loranger (New Riders Press, 2006)

  • Designing Interfaces: Patterns for Effective Interaction Design, by Jenifer Tidwell (O’Reilly, 2005)

  • Web Accessibility: Web Standards and Regulatory Compliance, by Andrew Kirkpatrick, Richard Rutter, Christian Heilmann, Jim Thatcher, and Cynthia Waddell (Friends of ED, 2006)

  • Ambient Findability, by Peter Morville (O’Reilly, 2005)

  • Bulletproof Web Design, second edition, by Dan Cederholm (New Riders Press, 2007)

  • Professional Search Engine Optimization with ASP.NET: A Developer’s Guide to SEO, by Cristian Darie and Jaimie Sirovich (Wrox Press, 2007)

Historically, building user-friendly software has always been easier with desktop applications than with web applications, simply because the Web lacked the technical tools to implement more complex features. Indeed, the Web was designed as a means of delivering simple documents formed of text, images, and links. However, as the Internet gets more mature, the technologies it supports become increasingly potent.

Many technologies have been developed—and are still being developed—to add flashy lights, accessibility, and power to web applications. Notable examples include Java applets, Flash, and Silverlight, which execute inside web browsers that have specific plugins installed. AJAX and ASP.NET AJAX have similar purpose, but on a different scale. They offer support for implementing lightweight rich internet applications without requiring additional plugins, while using a simpler programming model.

AJAX and Web 2.0

These days it’s increasingly harder to discuss AJAX without mentioning Web 2.0 ( http://en.wikipedia.org/wiki/Web_2 ). What is Web 2.0? Some say it is simply a marketing buzzword without any special meaning, while others use this term to describe the new open, interactive web that facilitates online information sharing and collaboration.

How did it start? In the words of Tim O’Reilly, who coined the term, Web 2.0 was born in 2004 after “a brainstorming session between O’Reilly and Medialive International”. As a result, a series of Web 2.0 conferences was born, and the term ended up gaining huge popularity.

Even today, we can find controversies about the definition of “Web 2.0”, but the version number is an obvious allusion to the recent changes of the World Wide Web. The initial goal of the Web addressed the delivery of static content in the form of text and images. The new generation of web applications tends to offer a richer user experience, much closer to that of desktop applications, while using live data from the Internet.

Initially, Web 2.0 was associated with the Semantic Web ( http://en.wikipedia.org/wiki/Semantic_web ). The Semantic Web is envisioned to be the next step in the Web’s evolution, based on online social-networking applications, using tag-based folksonomies (user-generated tags for data categorization). W3C director Tim-Berners Lee stated that “people keep asking what Web 2.0 is. I think maybe when you’ve got an overlay of scalable vector graphics - everything rippling and folding and looking misty - on Web 2.0 and access to a semantic Web integrated across a huge space of data, you’ll have access to an unbelievable data resource”.

Even if the services offered by Web 2.0 are far away from those aimed by the Semantic Web, where machines are able to understand and extract meanings from the content they offer, Web 2.0 still represents a step forward. In the world of Web 2.0 AJAX plays an essential role, offering the technological support for implementing rich and responsive Web interfaces.