Advanced ASP.NET AJAX Server Controls For .NET Framework 3.5

Advanced ASP.NET AJAX Server Controls For .NET Framework 3.5

Advanced ASP.NET AJAX Server Controls For .NET Framework 3.5

Advanced ASP.NET AJAX Server Controls For .NET Framework 3.5

eBook

$35.99  $47.99 Save 25% Current price is $35.99, Original price is $47.99. You Save 25%.

Available on Compatible NOOK devices, the free NOOK App and in My Digital Library.
WANT A NOOK?  Explore Now

Related collections and offers


Overview

ASP.NET AJAX server controls can encapsulate even the most powerful AJAX functionality, helping you build more elegant, maintainable, and scalable applications. This is the first comprehensive, code-rich guide to custom ASP.NET AJAX server controls for experienced ASP.NET developers. Unlike other books on ASP.NET AJAX, this book focuses solely on server control development and reflects the significant improvements in ASP.NET 3.5 AJAX and the latest Visual Studio 2008 features for streamlining AJAX development

 

Adam Calderon and Joel Rumerman first review the core Microsoft AJAX Library and JavaScript techniques needed to support a rich client-side experience. Next, they build upon these techniques showing how to create distributable AJAX-enabled controls that include rich browser-independent JavaScript client-side functionality. The authors thoroughly explain both the JavaScript and .NET aspects of control development and how these two distinct environments come together to provide a foundation for building a rich user experience using ASP.NET AJAX.

 

  • Create object-oriented cross-browser JavaScript that supports .NET style classes, interfaces, inheritance, and method overloading
  • Work with components, behaviors, and controls, and learn how they relate to DOM elements
  • Learn Sys.Application and the part it plays in object creation, initialization, and events in the Microsoft AJAX Library
  • Build Extender and Script controls that provide integrated script generation for their corresponding client-side counterparts
  • Localize ASP.NET AJAX controls including client script
  • Discover ASP.NET AJAX client and server communication architecture and the new support for Windows Communication Foundation (WCF)
  • Understand ASP.NET AJAX Application Services
  • Create custom Application Services
  • Design controls for a partial postback environment
  • Understand the AJAX Control Toolkit architecture and the many features it provides
  • Develop highly interactive controls using the AJAX Control Toolkit
  • Understand AJAX Control Toolkit architecture and build controls that utilize the toolkit

 


Product Details

ISBN-13: 9780132701488
Publisher: Pearson Education
Publication date: 06/26/2008
Series: Microsoft Windows Development Series
Sold by: Barnes & Noble
Format: eBook
Pages: 648
File size: 17 MB
Note: This product may take a few minutes to download.

About the Author

Adam Calderon is a C# MVP and the Application Development Practice Lead at InterKnowlogy. He is an accomplished software developer, author, teacher, and speaker with more than 14 years of experience designing and developing solutions on the Microsoft platform. His involvement with ASP.NET AJAX began in late 2005 with his participation in the ASP.NET ATLAS First Access program and later as a member of the UI Server Frameworks Advisory Council. Adam was one of the fortunate few who were able to work on a production application that utilized ASP.NET AJAX in its alpha form and experienced firsthand the trials and tribulations of working in “beta land” on this exciting technology. Visit Adam's blog at http://blogs.interknowlogy.com/adamcalderon.

 

Joel Rumerman is a Senior .NET Developer at the CoStar Group, where he develops ASP.NET applications to support the company’s commercial real estate information business. He is an adept software developer with more than eight years of experience developing .NET applications and is active in the San Diego .NET community as an author and speaker. Joel has been working with ASP.NET AJAX since late 2005 when he started work on a large-scale application for a worldwide independent software vendor. This initial entry into the ASP.NET AJAX world provided him invaluable experience as he worked closely with Microsoft as a member of the ATLAS First Access program and participated in a Strategic Design Review of the technology. Joel has gone on to implement many more solutions using ASP.NET AJAX, including a Virtual Earth mash-up that maps commercial real estate properties. Visit Joel's blog at http://seejoelprogram.wordpress.com.

 

 

Table of Contents

Foreword xxv

Preface xxvii

Acknowledgments xxxv

About the Authors xxxix

 

Part I: Client Code

Chapter 1: Programming with JavaScript 3

Chapter 2: Microsoft AJAX Library Programming 51

Part II: Controls

Chapter 3: Components 121

Chapter 4: Sys.Application 169

Chapter 5: Adding Client Capabilities to Server Controls 207

Chapter 6: ASP.NET AJAX Localization 255

Chapter 7: Control Development in a Partial Postback Environment 317

Part III: Communication

Chapter 8: ASP.NET AJAX Communication Architecture 371

Chapter 9: Application Services 425

Part IV: AJAX Control Toolkit

Chapter 10: ASP.NET AJAX Control Toolkit Architecture 481

Chapter 11: Adding Client Capabilities to Server Controls Using the ASP.NET AJAX Control Toolkit 513

Appendixes

Appendix A: JavaScript in Visual Studio 2008 547

Appendix B: Validating Method Parameters 555

Appendix C: ASP.NET Handlers and Modules 559

Appendix D: Client Error Handling Code 569

 

Index 577

Preface

Preface

Preface

Introduction

Server controls are an integral aspect of every ASP.NET application we build. They encapsulate browser appearance and server functionality in a reusable object. They can be used across multiple pages within a single ASP.NET application as well as across multiple ASP.NET applications. ASP.NET comes with a lot of prebuilt server controls. We have simple controls such as the label and we have complex controls such as the GridView. We also have the ability to create our own server controls to meet a need not met by one of the existing controls by inheriting from the appropriate base class and overriding its methods as needed.

This model of using server controls to encapsulate browser appearance and server functionality has served our needs well since the inception of ASP.NET 1.0, but our server control needs are changing.

A new server control need that has recently surfaced is the ability to incorporate Ajax functionality directly into the server control.

This need arose because our web applications need to be more responsive and visually interactive than the traditional ASP.NET repaint-the-entire-screen model and therefore the traditional server control supplies. This requirement has emerged because users are using web sites such as Gmail, Live.com, Yahoo! Mail, and others that don't repaint the screen every time they click a button or need to receive fresh data. Rather, they rely on Ajax to fetch fresh data and then update or add to a portion of the screen based upon that data. Because these web sites are heavily used and users really enjoy their experience while using these websites they expect other web sites to perform with the same elegance as they do. When a web site doesn't perform with the same elegance the user will often move onto another web site that does. Those popular applications have raised the bar for what is an acceptably user-friendly web site.

Because our users are demanding a web site experience that essentially uses Ajax and we build our ASP.NET web sites using server controls, we need a way of easily creating server controls that not only encapsulate browser appearance and server functionality, but also include Ajax functionality so that the server control itself is Ajax-enabled.

Taking a step back for a moment, unlike other technologies you might have read books on, ASP.NET AJAX server controls don't provide you with anything that you couldn't already do. We've always been able to embed Ajax-functionality into server controls ... it was just a real pain.

There were a few different methods we could use to include the JavaScript with our server control such as embedding it as a resource, but we eventually ended up having to do the same three tasks. To make our server control have some serious client capabilities we always had to concatenate strings together to form JavaScript statements and functions, write browser sniffing statements to make sure that the JavaScript was cross-browser compatible, and add attributes or render out Html that attached the JavaScript functionality to the client versions of our server controls. It wasn't impossible, but it was error-prone and there was always this mingling of server code and JavaScript that was hard to maintain and even harder to read.

Furthermore, if you had multiple server controls that had client capabilities it was difficult (but not impossible) to ensure that the client functions that each server control required didn't overwrite each other when rendered on the browser. Tracking down that problem was always a fun hour or so.

The difficulty grew exponentially if we wanted to include a mechanism for asynchronously communicating with the server when the user pressed a button embedded in the server control. Even with a helper communication library there were always tricks to getting your control to communicate properly with the server.

These hindrances were problematic enough to lead to some bad programming habits and bad code as well as scare programmers away from even attempting to include Ajax-functionality in their server controls.

These problems are what Microsoft's ASP.NET AJAX solves.

In this book, we're going to teach you how to use ASP.NET AJAX to create server controls that encapsulate Ajax functionality. ASP.NET AJAX provides both server and client programming constructs that make adding Ajax-capabilities to our server controls easy. Not to sound cliché, but with ASP.NET AJAX reducing the complexity of adding Ajax-capabilities to our server controls, we're able to create server controls whose Ajax capabilities are only limited by our creativity. If we want to listbox that self-updates with fresh data, if we want a type-ahead textbox that dynamically populates from the server, or if we want a button submits an address for verification we can easily accomplish this through ASP.NET AJAX.

The ASP.NET AJAX Components

As we go through the book we'll be talking about the three sections of ASP.NET AJAX: the Microsoft AJAX Library, the ASP.NET 2.0 AJAX Extensions, and the ASP.NET AJAX Control Toolkit. Here's a quick rundown of the different components.

Microsoft AJAX Library

The Microsoft AJAX Library is the JavaScript programming framework of ASP.NET AJAX. It provides all of the client programming constructs you'll use to create new client objects and components. It's contained within the MicrosoftAjax.js JavaScript file that's embedded in the System.Web.Extensions DLL.

ASP.NET 2.0 AJAX Extensions

The ASP.NET 2.0 AJAX Extensions are server objects such as the ScriptManager, ScriptControl, and ScriptDescriptor, which provide a connection between the Microsoft AJAX Library and our server ASP.NET development. These server objects provide an important distinction between ASP.NET AJAX and other Ajax frameworks as they provide a server programming model for manipulating client code (and allow us to make Ajax-enabled server controls!). Like the Microsoft AJAX Library they are included in the System.Web.Extensions DLL.

ASP.NET AJAX Control Toolkit

The ASP.NET AJAX Control Toolkit is a shared source project that is built on top of ASP.NET AJAX. It's an effort shared between Microsoft and the ASP.NET AJAX Community in with the goal of developing powerful and reusable ASP.NET AJAX extenders and controls.

It's not actually part of ASP.NET AJAX, but because it provides so many great server and extender controls, it's invaluable to the ASP.NET AJAX community. Creating new extender controls through it will be a topic we'll cover fully.

Book Breakdown

The book is divided into four major sections. In the first section, we focus on the basics of the Microsoft AJAX Library and JavaScript, the programming language that powers it. We call this section "Client Code." In the second section we focus on a creating distributable Ajax-enabled controls and we call this section "Controls." In the third section called "Communication" we focus on the different ways your client control can communicate with the server. Finally, in the fourth section, we focus on the Ajax Control Toolkit, which is a slightly higher-level model of creating Ajax-enabled server controls. This final section is aptly named "Ajax Control Toolkit."

Client Code

Chapter 1 focuses on JavaScript, the programming language that powers the Microsoft AJAX Library. We spend a full chapter on JavaScript because so many developers (ourselves included) have glossed over key details when working with the language and since you're going to be writing so much JavaScript to Ajax-enable your server controls a solid background is important.

In Chapter 2 we continue where we left off in Chapter 1 by taking a look at how the Microsoft AJAX Library builds upon JavaScript to provide a programming platform a .NET developer will find familiar.

Controls

Starting in Chapter 3 we begin our path to creating fully encapsulated Ajax-enabled controls by learning how to use and derive from three key client types: Components, Controls, and Behaviors. We'll talk theory as well as provide a couple of practical examples.

In Chapter 4 we cover maybe the most important portion of the Microsoft AJAX Library as we cover Sys.Application and how it acts like a client runtime with which we can interact.

Finally, in Chapter 5 we bring the server into the mix when we cover how to create server Components, Controls, and Behaviors that automatically create their corresponding client objects.

In Chapter 6 we wrap up the Controls section with an in-depth examination of Localization in ASP.NET AJAX.

Communication

With Chapter 7 we start looking at communication in ASP.NET AJAX using WCF services, page methods, and the client web service proxies.

In Chapter 8 we cover the application services and include a demonstration on how to build your own application service.

In Chapter 9 we conclude our communication section with a look at some of the concerns surrounding how the UpdatePanel effects control development.

Ajax Control Toolkit

Beginning with Chapter 10 we start our look at the Ajax Control Toolkit. We cover the base classes that are used by toolkit controls as well the support and designer classes that provide additional features.

Finally, we conclude the book with Chapter 11 as we attach client capabilities to server controls using the Ajax Control Toolkit. This chapter includes how to build a new extender control and provide design time features for it.

What is not covered?

You might find it strange to see a section that talks about what we're not covering. We're including it for two reasons.

First, this book covers a pretty narrow topic when compared to ASP.NET AJAX at large. Because of this we don't have the normal introductory chapter where we walk you through the basics or history of ASP.NET AJAX. Rather, we're going to make the assumption, good or bad, that you've got some ASP.NET AJAX knowledge under your belt. If you don't, don't worry, getting your ASP.NET AJAX knowledge to the point where you feel comfortable doesn't take very long and this book will pick up right where that basic knowledge leaves off. For this type of information Microsoft's ASP.NET AJAX website located at http://asp.net/ajax is an excellent source.

Second, we're leaving out a very familiar ASP.NET AJAX subject and we wanted a chance to tell you and defend our decision before we got too far. This is something that we've repeatedly debated between the two of us as well as asked many colleagues for their opinion and was a decision that we didn't come to easily.

There are no chapters where we cover how to use the UpdatePanel server control.

Ok, you haven't closed the book? Good. Let's explain how and why we came to this decision.

Simply put, the UpdatePanel is a server control. It comes with ASP.NET AJAX and provides a quick and dirty way to refresh a portion of a page such that the page goes through its normal lifecycle, but doesn't refresh the entire page when the page processing is done. Using it, we don't have to alter the way we've been programming web pages since ASP.NET 1.0 came out. This is a good thing and was a "quick win" for Microsoft. It allowed ASP.NET AJAX to be adopted very quickly by ASP.NET developers and provided a unique advantage against other Ajax frameworks.

However, the UpdatePanel is just a server control and it's developed in such a way that it doesn't have a whole lot of comparative properties with the type of ASP.NET AJAX server control development we're covering.

We're not saying it's not an important server control and that it has no place in the Ajax world. Rather, it is an extremely valuable tool whose complexity and correct usage is worthy of a small book; just not this one.

Finally, while we're not going to cover how to use the UpdatePanel we are going to cover how to create server controls so that they work correctly in an UpdatePanel, or more specifically a partial-postback, environment. We expect that you want your new server controls to work in any ASP.NET environment and a partial-postback environment is no exception. The partial-postback environment, however, requires us to use some different methods, the new ScriptManager.RegisterXXX methods being the most common, and take some care in how we create our server controls. So, we've dedicated Chapter 9 Partial Page Rendering to this topic.

Why'd we write a Book on Just Server Controls?

Writing a book on just server controls affords us the ability to dive deeply into a narrow topic that is extremely important to web application developers. The ASP.NET AJAX books that currently exist are all generally focused on the technology as a whole. Because they cover a broad range of topics, giving a taste of everything, they have trouble really getting into how certain parts of ASP.NET AJAX work and tend to give shallow coverage of topics that we think are key to creating server controls. It's been our experience that developers tend to move past the content of the more general books fairly quickly as non-basic situations arise almost immediately when working on a real life web application.

Who is the Target Audience?

This book is primarily targeted at the experienced ASP.NET developer who has developed custom web server controls. We expect that you're reading this book to enhance your already proficient ASP.NET development skill set with new ASP.NET AJAX skills. The applications you develop demand elegance and professionalism as well as easy maintenance and scalability so you tend to use server controls to your advantage wherever possible.

Besides your experience with ASP.NET, we expect that you're familiar with JavaScript and the basics of ASP.NET AJAX. As such, we won't be covering how to set up a new ASP.NET AJAX-enabled web application and while we will cover JavaScript, we start our coverage at a level where we assume some existing knowledge.

Our goal is to provide you with the tools you need to build reusable ASP.NET AJAX Server Control or Ajax Control Toolkit Extender Controls. Our feeling is that a reasonably knowledgeable ASP.NET developer will be able to learn the skills necessary to create new ASP.NET AJAX server controls through this book and then add that skill to their ASP.NET development tool bag.

Pre-requisites

This book requires ASP.NET 3.5 AJAX and Visual Studio 2008. We heavily cover features included in ASP.NET 3.5 AJAX not included in ASP.NET 2.0 AJAX as well as C#'s and Visual Studio 2008's new capabilities such as automatic properties and JavaScript IntelliSense.

© Copyright Pearson Education. All rights reserved.

From the B&N Reads Blog

Customer Reviews