Preface

ASP.NET 2.0 with AJAX is arguably the fastest, most efficient, most reliable and best supported way to create interactive web applications available today. Combined with the development tools available from Microsoft, both free and commercial, it is incredibly easy to create web sites that look great and perform well. Best of all, most of the “plumbing” (security, data access, layout, and so on) is taken care of for you by the .NET Framework.

About This Book

This book will teach you how to build professional quality, interactive, robust data driven web applications using Visual Basic 2005. In addition, your applications will be highly interactive and data driven—must-have features in today’s feature-rich web world.

ASP.NET is not difficult. All of the concepts are straightforward, and the Visual Studio and Visual Web Developer environments simplify the process of building powerful web applications. The difficulty in ASP.NET is only that it is so complete and flexible that there are many pieces that must be woven together to build a robust, scalable, and efficient application. This book cuts to the heart of the matter, showing in clear, easy-to-follow steps, how to understand and build a web site.

Because there are three authors’ names on this book, you might be concerned that the tone will be uneven. Every possible measure has been taken to avoid this. Although each chapter was originally written by one author, they were edited by all three. Every chapter was then extensively edited and rewritten by me, Jesse Liberty, to give the book a single voice. If that weren’t enough, the chapters were subsequently edited by O’Reilly editors as well as independent tech editors, and once more by the authors. The bottom line is that while three individuals wrote this book, you should find it reads as if written by just one. This system has worked well with my previous books. If not, please be sure to let me know by dropping a note in my support forum (http://forums.delphiforums.com/JesseLiberty ) .

About This Series

O’Reilly Learning books are written and designed for anyone who wants to build new skills and who prefers a structured approach to studying. Each title in this series makes use of learning principles that we (with your help) have found to be best at equipping you with the knowledge you need for joining that new project, for coping with that unexpected assignment from your manager, or for learning a new language in a hurry.

To get the most out of any book in the Learning series, we recommend you work your way through each chapter in sequence. You’ll find that you can get a quick grasp of a chapter’s content by reading the instructional captions we’ve written for its examples and figures. You can also use the chapter Summary to preview its key takeaways and to review what you have learned. Most chapters feature a sample application, and, if you learn best by reading code, you can turn to the complete source listing that appears just before the Summary. To bridge any gaps in your knowledge, check out the Cheat Sheets. Finally, to help you test your mastery of the material in each chapter, we conclude with a Brain Builder section, which includes a short quiz and some hands-on exercises.

Learning books work with you as you learn—much as you would expect from a trusted colleague or instructor—and we strive to make your learning experience enjoyable. Tell us how we’ve done by sending us praise, brickbats, or suggestions for improvements to .

Learning or Programming?

We have written two ASP.NET books: the one you are currently reading and another named Programming ASP.NET 2.0. This book, Learning ASP.NET 2.0 with AJAX is intended for beginning ASP.NET developers, and answers the question: “What is the quickest way for me to build real web applications with the least handcoding?”

Our other book, Programming ASP.NET is for developers who are saying: “Help me learn—in depth; show how everything works, and then help me put it to work in web applications.” The key difference is this book is aimed to make you productive quickly, while the second book is designed to explore the technology in detail. They complement each other, but if you are starting out and want to get to work fast, this is the one for you.

Learning ASP.NET 2.0 with Ajax assumes you know some HTML and have either some familiarity with Visual Basic 2005 (VB) or C#, or can pick up what you need along the way. (Or you’re willing to run right out and buy Programming Visual Basic 2005 by Jesse Liberty, although for what you’ll be doing here, you won’t really need it). To help with this, we have included VB Cheat Sheets throughout the book to explain and clarify some of the VB topics for newbies.

VB Versus C#

A quick note on Visual Basic versus C#: Some people choose a .NET book based on what language the examples are given in. That’s a natural reaction, but it’s really not necessary, and here’s why: There is very little actual VB or C# code in any given ASP.NET program, and what there is, you can easily translate from one to the other “on inspection.” Besides, the two languages are strikingly similar. If you know one, it’s quite simple to learn the other. In fact, there are software tools that can convert one language to the other with amazing accuracy. Finally, ASP.NET programmers benefit terrifically by being “bilingual”—that is, having the ability to read VB and write C# (or vice versa).

How This Book Is Organized

Chapter 1, Getting Started, walks you through creating your first web site, HelloWorld.

Chapter 2, Building Web Applications, goes over the fundamentals of web sites and covers the basic controls available to you in ASP.NET.

Chapter 3, Snappier Web Sites with AJAX, shows you how to integrate this powerful client-side technology into your pages.

Chapter 4, Saving and Retrieving Data, shows you how to make your site interact with data stored in a database. You have controls to retrieve data, allow your users to interact with that data, and then save it back to the database.

Chapter 5 looks at Validation. ASP.NET provides extensive support for data validation, including ensuring that a choice has been made, checking that values are within a range, and matching regular expressions.

Chapter 6, Style Sheets, Master Pages, and Navigation, shows you how to make web sites that are professional quality, good looking, consistent, and easy to navigate.

Chapter 7 examines State and Life Cycle in ASP.NET. Understanding how, and in what order, a page and its controls are created on the server and rendered to the browser is crucial for building successful interactive web sites. State is the current value of everything associated with the page. This is mostly handled automatically, but this chapter shows you how useful it can be to the developer.

Poop happens. Chapter 8, Errors, Exceptions, and Bugs, Oh My!, shows you how to deal with unexpected problems, and also how to debug your application.

Chapter 9, Security and Personalization, shows how you can protect your web site from malicious users. A related topic is personalization, which allows your end users to customize the look and feel of the web site according to their personal preferences. You will see how to use themes and skins to accomplish this.

Chapter 10, Putting It All Together, is a single, large example that integrates every-thing you have learned throughout the book.

Appendix A, Installing the Applications, tells you what hardware and software is required to run the examples in this book, and helps you set up your environment.

Appendix B, Copying a Web Site, describes the process of copying a web site to a new web site. This is a technique used often throughout this book when building up examples.

Appendix C, Answers to Quizzes and Exercises, presents detailed solutions to all the quiz questions and practice exercises found at the end of each chapter.

Conventions Used in This Book

The following font conventions are used in this book:

Italic

Used for pathnames, filenames, program names, Internet addresses, such as domain names and URLs, and new terms where they are defined.

Constant width

Used for command lines and options that should be typed verbatim, and names and keywords in program examples. Also used for parameters, attributes, expressions, statements, and values.

Constant width italic

Used for replaceable items, such as variables or optional elements, within syntax lines or code.

Constant width bold

Used for emphasis within program code examples.

Pay special attention to notes set apart from the text with the following icons:

Tip

This is a tip. It contains useful supplementary information about the topic at hand.

Warning

This is a warning. It helps you solve and avoid annoying problems.

Support: A Note from Jesse Liberty

I provide ongoing support for my books through my web site. You can obtain the source code for all of the examples in Learning ASP.NET at:

http://www.LibertyAssociates.com

There, you’ll also find access to a book support discussion group that has a section set aside for questions about Learning ASP.NET. Before you post a question, how-ever, please check my web site to see if there is a Frequently Asked Questions (FAQ) list or an errata file. If you check these files and still have a question, then please go ahead and post it to the discussion center. The most effective way to get help is to ask a precise question or to create a small program that illustrates your area of concern or confusion, and be sure to mention which edition of the book you have (this is the first edition).

Using Code Examples

This book is here to help you get your job done. In general, you may use the code in this book in your programs and documentation. You do not need to contact us for permission unless you’re reproducing a significant portion of the code. For example, writing a program that uses several chunks of code from this book does not require permission. Selling or distributing a CD-ROM of examples from O’Reilly books does require permission. Answering a question by citing this book and quoting example code does not require permission. Incorporating a significant amount of example code from this book into your product’s documentation does require permission.

We appreciate, but do not require, attribution. An attribution usually includes the title, author, publisher, and ISBN. For example: “Learning ASP.NET 2.0 with AJAX, by Jesse Liberty, Dan Hurwitz, and Brian MacDonald. Copyright 2007 Jesse Liberty and Dan Hurwitz, 978-0-596-51397-9.”

If you feel your use of code examples falls outside fair use or the permission given above, feel free to contact us at http://permissions@oreilly.com.

We’d Like to Hear from You

Please address comments and questions concerning this book to the publisher:

O’Reilly Media, Inc.
1005 Gravenstein Highway North
Sebastopol, CA 95472
800-998-9938 (in the United States or Canada)
707-829-0515 (international or local)
707-829-0104 (fax)

We have a web page for this book, where we list errata, examples, and any additional information. You can access this page at:

http://www.oreilly.com/catalog/9780596513979

To comment or ask technical questions about this book, send email to:

http://bookquestions@oreilly.com

For more information about our books, conferences, Resource Centers, and the O’Reilly Network, see our web site at:

http://www.oreilly.com/

Visit the O’Reilly .NET DevCenter:

http://www.oreillynet.com/dotnet

Safari® Books Online

When you see a Safari® Books Online icon on the cover of your favorite technology book, that means the book is available online through the O’Reilly Network Safari Bookshelf.

Safari offers a solution that’s better than e-books. It’s a virtual library that lets you easily search thousands of top tech books, cut and paste code samples, download chapters, and find quick answers when you need the most accurate, current information. Try it free at http://safari.oreilly.com.

Acknowledgments

From Jesse Liberty

I am particularly grateful to John Osborn who has shepherded all my work through O’Reilly as well as the editors and production folk at O’Reilly who (as always) made this book so much more than what we originally created.

From Dan Hurwitz

In addition to the people mentioned by Jesse, as always I especially want to thank my wife for being so supportive of this project. It sounds trite and repetitious, but it would not be possible without her help.

From Brian MacDonald

My thanks, first and foremost, go to Jesse and Dan for inviting me to be a part of this project. My deepest appreciation goes to John Osborn for getting me involved with O’Reilly in the first place, many years ago now. Thanks as well to Dan Maharry for his technical feedback, especially on the exercises. Finally, thanks to my wife, Carole, who provided technical as well as emotional support, and to my son, Alex. You both put up with a lot of my absences while I worked on this book, and I thank you for it.

Get Learning ASP.NET 2.0 with AJAX now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.