John Paul Mueller
CONTENTS AT A GLANCE
• Discovering Visual Web Developer
• Using Built-in Features
• Creating Simple but Effective Pages
• Working with Dynamic Data
• Developing Full-blown Web Applications
• The Finishing Touches: Debug, Secure, and
• Application Development Within the Corporate Environment
Appendices
• Using Built-in Features
• Creating Simple but Effective Pages
• Working with Dynamic Data
• Developing Full-blown Web Applications
• The Finishing Touches: Debug, Secure, and
• Application Development Within the Corporate Environment
Appendices
About the Author
John Mueller is a freelance author and technical editor. He has writing in his blood, having produced 68 books and over 300 articles to date. The topics range from networking to artificial intelligence and from database management to heads down programming. Some of his current books include a Windows power optimization book, a book on .NET security, and books on Amazon Web Services, Google Web Services, and eBay Web Services. His technical editing skills have helped over 39 authors refine the content of their manuscripts. John has provided technical editing services to both Data Based Advisor and Coast Computemagazines. He’s also contributed articles to magazines like DevSource, InformIT, SQL Server Professional, Visual C++ Developer, Hard Core Visual Basic, asp.netPRO, Software
Test and Performance, and Visual Basic Developer
. He’s currently the editor of the .NET electronic newsletter
for Pinnacle Publishing (http://www.freeenewsletters.com/).
When John isn’t working at the computer, you can find him in his workshop. He’s an avid woodworker and candle maker. On any given afternoon, you can find him working at a lathe or putting the finishing touches on a bookcase. He also likes making glycerin soap and candles, which comes in handy for gift baskets. You can reach John on the Internet at
JMueller@mwt.net. John is also setting up a Web site at:
http://www.mwt.net/~jmueller/; feel free to look and make suggestions on how
he can improve it. One of his current projects is creating book FAQ sheets that should help you find the book information you need much faster.
Introduction
It seems like a very long time since Microsoft first announced Whidbey and eventually delivered
the first beta. In fact, it seems like Microsoft is taking a long time to do anything these days. Some people misinterpret these long delays as a lack of enthusiasm or that perhaps the spark has just gone out of Microsoft’s development process. One look at the completed Visual Studio and the many topics discussed in this book should convince you otherwise. Microsoft has done one thing more than with any other previous release of Visual Studio—they’ve listened. I won’t go so far as to say that you’ll find every feature of your dreams, but Microsoft has gone a long way toward making Visual Studio the kind of product that developers will enjoy using.
Mastering Web Development with Microsoft Visual Studio 2005
makes the inevitable transition easier by pointing out details of all these changes and then providing code to show you how to use them. Unlike a pure ASP.NET book, you’ll also discover a wealth of techniques for combining coding methods you use at the desktop with those that you now need to use on the Web site.
While reading and using Mastering Web Development with Microsoft Visual Studio 2005, you’ll create a large-scale corporate Web site for ABC, Incorporated. In short, instead of simply discovering what ASP.NET provides, you’ll actually put this information into action by building a
complex Web site.
So What’s in Visual Studio for Me?
If you like going home on weekends and don’t like banging your head against the proverbial
brick wall, Visual Studio 2005 has a lot to offer you. Every developer is going to love working
with master pages and themes. The current development process often has developers looking
for odd techniques to get repeated content onto a page. Master pages make the process extremely
fast and easy. The ABC Incorporated Web example used in the majority of this book demonstrates
the full effect of master pages on development. You’ll find that the pages look very consistent,
yet the book will show you that the repeated material is included only once. Themes add to
master pages by letting you give your Web site a consistent feel. Every page uses the same colors
automatically. Of course, you might want to give your users a choice. The ABC Incorporated
Web example that runs through much of this book shows you how to do that too. A simple
change on the main page lets a user switch between any number of themes.
You’ll find the amount of drag-and-drop functionality has increased as well. For example,
you’ll be amazed at how fast you can create complex pages that rely on database input using
drag-and-drop techniques.
Mastering Web Development with Microsoft Visual Studio 2005
shows you how to improve on drag and drop using SmartTag technology. Simply click an arrow next to a control to see a SmartTag you can use to configure it. This feature is especially helpful in getting database applications put together quickly. The ABC Incorporated Web site example
includes a number of database examples—everything from a shopping cart to a beneficial suggestions
Web application. In fact, you’ll see just how easy it is to use XML for database purposes in this
example—one of the database examples relies on XML instead of SQL Server.
This book also examines new uses for some existing tools. Many developers aren’t familiar with
everything that Server Explorer can do. Microsoft has made improvements to Server Explorer that make it a must-use tool for development. You’ll find an entire chapter on this important topic. By using Server Explorer effectively, you can cut the time required to create any application significantly.
One of the most interesting new features in Visual Studio is WebParts. Imagine providing a little
extra code that lets users move items around, get rid of items they don’t want, and add items back in when they remove too much—all without bothering you. That’s the beauty of WebParts. You provide all of the content that anyone will need and the individual users choose what they want. No longer do you have to contend with requests for little time-consuming tweaks to your Web page design that someone else will want changed.
I could go on—Visual Studio has a wealth of impressive new Web development features and
you’ll find the majority of them discussed in the book. One of Microsoft’s apparent, less stressed,
goals was obviously to simplify things for the developer. Let’s face it, most developers don’t
have time any longer to fiddle with poorly implemented features.
Mastering Web Development with Microsoft Visual Studio 2005
helps you understand these new features and get to work quickly using
all of the Visual Studio 2005 functionality.
Goals for Writing this Book
One of the major goals for writing this book is to discover the real world functionality of ASP.NET 2.0. Rather than simply assume that something probably wouldn’t work or that Visual Studio had a limitation
I couldn’t overcome, I assaulted all of the boundaries. The result is this book, which discusses
a broad range of programming topics. In fact, you’ll be surprised at the number of things that Visual Studio can do—I know that I was pretty amazed by the time I completed this project.
Of course, testing the boundaries is nice, but you need practical examples too. You’ve seen many
examples designed for the corporate market in the past and frankly, at least according to the email
messages I receive, most of them are so hard to understand that it’s a wonder anyone gets anything out of them at all. Consequently, one of the goals for this book was to create a large-scale example that anyone can understand. The ABC Incorporated example breaks all of the complex code down into easily understood parts. The main menu tells you precisely where to find a particular piece of the puzzle in the book—no guesswork involved. All you need to do is play around with the example, determine what you’d like to do, and go to that part of the book. It’s really that simple.
Finally, this book helps you discover whether Microsoft is telling the truth about the usefulness
and effectiveness of this product. Is Visual Studio really a good tool for creating Web sites? After all, you have a lot of tools from which to choose. I think you’ll be surprised at just how easy it is to create Web sites that not only look professional, but don’t require a lot of time to build. This book demonstrates that Visual Studio can help you create Web sites of moderate size without the usual array of widgets and lost time of other products. You can get to work almost immediately and use this book as a guide while you create the masterpiece that is your Web site.
Who Should Read This Book?
This book isn’t for everyone. I created a book for someone who wants to see what ASP.NET 2.0 and the .NET Framework 2.0 provide, but who doesn’t want to spend a lot of time and effort doing it. This doesn’t mean, however, that you won’t get highly developed, large-scale results: I targeted all of the examples toward the needs of an enterprise developer. All of the discussion considers this audience too. You won’t find a small, flimsy home network example in this book. All of the applications are robust and designed to show specific Visual Studio Web development features. This book even includes sections on design strategies for larger application.
NOTE
Don’t get the idea that I didn’t think about the small business or hobbyist developer. My
book, Mastering Microsoft Visual Web Developer 2005 Express Edition
(Sybex 2006), discusses ASP.NET from a small-scale development perspective.
You do need to have certain knowledge to use this book. I’m assuming that you’ve worked with
your computer long enough to understand how it works—you won’t find any button clicking exercises in this book. It’s also important that you know a programming language at least a little bit. This book doesn’t provide basic instruction on either Visual Basic or C#; the two languages used for the examples. Consequently, if you don’t know a loop from an object, you probably need to look through a language book before getting this one, such as Mastering Visual Basic 2005
by Evangelos Petroutsos (Sybex, 2006).
the first beta. In fact, it seems like Microsoft is taking a long time to do anything these days. Some people misinterpret these long delays as a lack of enthusiasm or that perhaps the spark has just gone out of Microsoft’s development process. One look at the completed Visual Studio and the many topics discussed in this book should convince you otherwise. Microsoft has done one thing more than with any other previous release of Visual Studio—they’ve listened. I won’t go so far as to say that you’ll find every feature of your dreams, but Microsoft has gone a long way toward making Visual Studio the kind of product that developers will enjoy using.
Mastering Web Development with Microsoft Visual Studio 2005
makes the inevitable transition easier by pointing out details of all these changes and then providing code to show you how to use them. Unlike a pure ASP.NET book, you’ll also discover a wealth of techniques for combining coding methods you use at the desktop with those that you now need to use on the Web site.
While reading and using Mastering Web Development with Microsoft Visual Studio 2005, you’ll create a large-scale corporate Web site for ABC, Incorporated. In short, instead of simply discovering what ASP.NET provides, you’ll actually put this information into action by building a
complex Web site.
So What’s in Visual Studio for Me?
If you like going home on weekends and don’t like banging your head against the proverbial
brick wall, Visual Studio 2005 has a lot to offer you. Every developer is going to love working
with master pages and themes. The current development process often has developers looking
for odd techniques to get repeated content onto a page. Master pages make the process extremely
fast and easy. The ABC Incorporated Web example used in the majority of this book demonstrates
the full effect of master pages on development. You’ll find that the pages look very consistent,
yet the book will show you that the repeated material is included only once. Themes add to
master pages by letting you give your Web site a consistent feel. Every page uses the same colors
automatically. Of course, you might want to give your users a choice. The ABC Incorporated
Web example that runs through much of this book shows you how to do that too. A simple
change on the main page lets a user switch between any number of themes.
You’ll find the amount of drag-and-drop functionality has increased as well. For example,
you’ll be amazed at how fast you can create complex pages that rely on database input using
drag-and-drop techniques.
Mastering Web Development with Microsoft Visual Studio 2005
shows you how to improve on drag and drop using SmartTag technology. Simply click an arrow next to a control to see a SmartTag you can use to configure it. This feature is especially helpful in getting database applications put together quickly. The ABC Incorporated Web site example
includes a number of database examples—everything from a shopping cart to a beneficial suggestions
Web application. In fact, you’ll see just how easy it is to use XML for database purposes in this
example—one of the database examples relies on XML instead of SQL Server.
This book also examines new uses for some existing tools. Many developers aren’t familiar with
everything that Server Explorer can do. Microsoft has made improvements to Server Explorer that make it a must-use tool for development. You’ll find an entire chapter on this important topic. By using Server Explorer effectively, you can cut the time required to create any application significantly.
One of the most interesting new features in Visual Studio is WebParts. Imagine providing a little
extra code that lets users move items around, get rid of items they don’t want, and add items back in when they remove too much—all without bothering you. That’s the beauty of WebParts. You provide all of the content that anyone will need and the individual users choose what they want. No longer do you have to contend with requests for little time-consuming tweaks to your Web page design that someone else will want changed.
I could go on—Visual Studio has a wealth of impressive new Web development features and
you’ll find the majority of them discussed in the book. One of Microsoft’s apparent, less stressed,
goals was obviously to simplify things for the developer. Let’s face it, most developers don’t
have time any longer to fiddle with poorly implemented features.
Mastering Web Development with Microsoft Visual Studio 2005
helps you understand these new features and get to work quickly using
all of the Visual Studio 2005 functionality.
Goals for Writing this Book
One of the major goals for writing this book is to discover the real world functionality of ASP.NET 2.0. Rather than simply assume that something probably wouldn’t work or that Visual Studio had a limitation
I couldn’t overcome, I assaulted all of the boundaries. The result is this book, which discusses
a broad range of programming topics. In fact, you’ll be surprised at the number of things that Visual Studio can do—I know that I was pretty amazed by the time I completed this project.
Of course, testing the boundaries is nice, but you need practical examples too. You’ve seen many
examples designed for the corporate market in the past and frankly, at least according to the email
messages I receive, most of them are so hard to understand that it’s a wonder anyone gets anything out of them at all. Consequently, one of the goals for this book was to create a large-scale example that anyone can understand. The ABC Incorporated example breaks all of the complex code down into easily understood parts. The main menu tells you precisely where to find a particular piece of the puzzle in the book—no guesswork involved. All you need to do is play around with the example, determine what you’d like to do, and go to that part of the book. It’s really that simple.
Finally, this book helps you discover whether Microsoft is telling the truth about the usefulness
and effectiveness of this product. Is Visual Studio really a good tool for creating Web sites? After all, you have a lot of tools from which to choose. I think you’ll be surprised at just how easy it is to create Web sites that not only look professional, but don’t require a lot of time to build. This book demonstrates that Visual Studio can help you create Web sites of moderate size without the usual array of widgets and lost time of other products. You can get to work almost immediately and use this book as a guide while you create the masterpiece that is your Web site.
Who Should Read This Book?
This book isn’t for everyone. I created a book for someone who wants to see what ASP.NET 2.0 and the .NET Framework 2.0 provide, but who doesn’t want to spend a lot of time and effort doing it. This doesn’t mean, however, that you won’t get highly developed, large-scale results: I targeted all of the examples toward the needs of an enterprise developer. All of the discussion considers this audience too. You won’t find a small, flimsy home network example in this book. All of the applications are robust and designed to show specific Visual Studio Web development features. This book even includes sections on design strategies for larger application.
NOTE
Don’t get the idea that I didn’t think about the small business or hobbyist developer. My
book, Mastering Microsoft Visual Web Developer 2005 Express Edition
(Sybex 2006), discusses ASP.NET from a small-scale development perspective.
You do need to have certain knowledge to use this book. I’m assuming that you’ve worked with
your computer long enough to understand how it works—you won’t find any button clicking exercises in this book. It’s also important that you know a programming language at least a little bit. This book doesn’t provide basic instruction on either Visual Basic or C#; the two languages used for the examples. Consequently, if you don’t know a loop from an object, you probably need to look through a language book before getting this one, such as Mastering Visual Basic 2005
by Evangelos Petroutsos (Sybex, 2006).
Table of Contents
Introduction . . . . . . . . . . . . . . . . . . . . xxiii
Part 1 • Discovering Visual Web Developer . . . . . . .. . . . . . 1
Chapter 1 • Working with Visual Web Developer . . . . . . . . . . . . . . . 3
Introducing Visual Web Developer . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Understanding What Visual Web Developer Provides . . . . . . . . . . . . . . . . 4
Understanding How Visual Web Developer Differs from Visual Web
Developer Express Edition . . . . . . . . . . . . . . . . . . . . . . 6
Understanding the ASP.NET 2.0 Difference . . . . . . . . . . . . . . . . . . . . . . 8
Performing the Visual Web Developer Setup . . . . . . . . . . . . . . . . . . . 10
Using the IDE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
An Overview of the IDE Elements . . . . . . .. . . . . . . . . . . . . . 11
Modifying the Visual Web Developer Options . . . . . . . . . . . . . . . . . . 15
Using Source View . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . 17
Using the Code View . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Working with the Personal Web Site Starter Kit . . . . . .. . . . . . . . . . . . . . . . . 21
Creating the Application . . . . . . . . . . . . . . . . . . . . . . . . 21
Working with the Application Elements . . . . .. . . . . . . . . . . . . . 22
Modifying the Application Template to Meet Specific Needs . . . . . 23
Defining the Enterprise Web Project . . . . . . . . . . . . .. . . . . . . . . . . . . . . 27
Defining Your Development Goals . . . . . . . . . . . . . . . . . . . . 27
Chapter 2 • Creating a Simple Application. . . . . . . . . . . . . . . . 29
Using the Built-in Web Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Advantages of Using the Built-in Web Server . . . . . . . . . . . . . 30
Disadvantages of Using the Built-in Web Server . . . . . . . . . . . . . 30
Creating the Application . . .. . . . . . . . . . . . . . . . . . . . . . . . . 31
Using the Build Toolbar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
Using the Standard Toolbar . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . 36
Finding and Replacing Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
Working with the Browser Emulator . . . . . . . . . . . . . . . . . . . . . . . . . . 43
Understanding Save/Refresh Style Page Development . . . . .. . . . . . . . . . . 44
Performing Tasks One at a Time . . . . . . . . . . . . . . . 44
Using the Task List Window . . . . . . . . . . . . . . . . . . . . . . .. . . . . . 44
Using the HTML Source Edit Toolbar . . . . . . . . . . . . . . . . . . . . 47
Working with Control SmartTags . . . . . . . . . . . . . . . . . .. . . . . . . . 48
Using Internet Information Server . . . . . . . . . . . . .. . . . . . . . . . 49
Working with Local IIS . . . . . . . . . . . . . . . . . . . . . . . . . 49
Creating New Projects with IIS . . . . . . . . . . . . . . . . . . . . . . . 50
Using the Copy Web Site Tool . . . . . . . . . . . . . . . . . . . . . . . . . 52
Designing Your Application Using Visio . . . . . . . . . . . . . . . . . 53
Deciding What to Create . . . . . . . . . . . . . . . . . . . 54
Designing a Site Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
Working with Existing Web Sites . . . . . . . . . . . . . . . . . . . . . . . 56
Defining Your Development Goals . . . . . . . . . . . . . . . . . . . 56
Chapter 3 • Using Server Explorer. . . . . . . . . . . . . . . . . . 59
Understanding Server Explorer . . .. . . . . . . . . . . . . . . . . . . . . . 59
Creating a Server Connection . . . . . . .. . . . . . . . . . . . . . . . . . . . 61
An Overview of Data Connections . . . . . . . . . . . . . . . . . . . 62
An Overview of Crystal Reports Services . . . . . . . . . . . . . . 64
An Overview of Message Queues . . . . . . . . . . . . . . . . . . . . . . . . . . 64
An Overview of Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
Working with Event Logs . . . . . . . . . . . . . . . . . . . 67
Using Standard Event Logs . . . . . . . . . . . . . . . . . . . . . . . 70
Working with Performance Counters . . . . . . . . . . . . . . . . . . . 71
Viewing Performance Counters . . . . . . .. . . . . . . . . . . . . 71
Creating a Simple Counter . . . . . . . . . .. . . . . . . . . . . . . . . . 76
Defining Your Development Goals . . . . . . . . .. . . . . . . . . . . 79
Part 2 • Using Built-in Features . . . . . . . . . . . . . . . . . . . . . 81
Chapter 4 • Working with ASP.NET 2.0 Master Pages and Themes . . . . . 83
Understanding Master Pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
Designing Master Pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
Creating the Master Page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
Using Existing Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
Defining the Master Page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
Creating a Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
Using the Layout Toolbar . . . . . . . . . . . . . . . . . . . . . 92
Creating a Project with Master Pages . . . . . . . . . . . . . . . . . . . . . . . . 97
Creating a Content Page Using a Master Page . . . . . . . . . . . . . . . . 97
Adding a Master Page to an Existing Web Page . . . . . . . . . . . . . . 99
Using Multiple Master Pages in a Project . . . . . . . . . . . . . . 100
Understanding Themes . . . . . . . . . . . . . . .. . . . . . . . . . . . 101
Designing Your Own Themes . . . . . . . . . . . . . . . . . . . . 102
Creating a Themes Folder . . . . . . . . . . . . . . . . . . . . . . . . . 102
Defining a CSS File for a Theme . . . . . . . . . . . . . . . . . . . . . . . . 102
Defining the SKIN File and Adding Theme Resources . . . .. . . . . . 102
Creating a Simple Project Using Themes . . . . . .. . . . . . . 104
Applying a Theme to a Page . . . . . . . . . . . . . . . . . . . 105
Applying a Theme to a Web Site . . . . . . . . . . . . . . . . 106
Working with Cascading Style Sheets (CSS) . . . . . . . . . . . . . 107
Using the Style Sheet Toolbar . . . . . . . . . . . . . . . . 107
Designing Flexible Interfaces . . . . . . . . .. . . . . . . . . . 108
Creating and Using a CSS File . . . . . . . . . . . . . . . . . . . . . . . . 109
Working with CSS in the Web Page . . . . . . . . .. . . . . . . . 111
Working with Microsoft Using the Web Toolbar . . . . . . . . . . . . . 112
Defining Your Development Goals . . . . . . . . .. . . . . . . . . . . . 113
Chapter 5 • Building Intelligent Pages . . . . . . . . . . 115
Understanding Server-side Intelligence . . . . . . . . . . . . . 116
Detecting the Client Configuration . . . . . . . . . . . . . . . . . 118
Working with Forms . . . . . . . . . . . . . . . . . . . . . . 123
Deciding between the GET and POST Data Handling Methods . . . . . . . . . . 124
Understanding the Four Levels of Data Processing . . . . . . . . . . . . 125
Processing Input Using the GET Method . . . . . . .. . . . . . . . . . . . 125
Processing Input Using the POST Method . . . . . . . . . . . . . . . 128
Understanding the New ASP.NET 2.0 Controls . . . . . . . . . . . . 130
Using XML Instead of HTML for Web Pages . . . . . .. . . . . . . . . 132
Creating the XML Content . . . . . . . . . . . . . . . . . . . . . . . . 132
Interpreting the XML Using XSLT . . . . . . . . . . . . . . . . . . 136
Learning More about XML . . . . . . . . . . . . . . . . . . . . . . . . . 139
Learning More about XSLT . . . . . . . . . . . . . . . . . . . 140
Developing a Privacy Policy . . . . . . . . . . . . . . . . . . . . . . . . . 140
Creating a Safe Environment for User Data . . . . . . .. . . . . . 143
Defining Your Development Goals . . . . . . . . . . . . . . . . . . . . . . 145
Chapter 6 • Working with Scripts . . . . . . . . . . . . . . . . 147
Understanding Client-side Intelligence . . . . . . . . . . . . .. . . . . . . . . 147
Using Basic Scripting Principles . . . . . . . . . . . . . . . . . . . . 150
Creating Efficient and Effective Scripts . . . . . . . . . . . . . 150
Debugging Your Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
Learning More about JavaScript . . . . . . . . . . . . . . . . . . 154
Working with Controls . . . . . . . . . . . . . . . . . . . . . . . . . 154
Working with HTML Tags . . . . . . . . . . . . 154
Using the <Object> Tag . . . . . . . . . . . . . . . 156
Relying on ASP.NET Controls . . . . . . . . . . . . . . . 165
Scripting with Client Callback . . . . . . . . .. . . . . . . . . . . . 167
Storing and Deleting Cookies . . . . . . . . . . . . . . . . . . 171
Creating and Reading Temporary Cookies . . . . . . . . . . . . . 171
Creating and Reading Permanent Cookies . . . . . . . . . . . . 175
Using WebParts to Automate User Customizations . . . . . . . . . 178
Adding the WebPartManager . . . . . . . . . . 178
Changing Selections Using a Custom Control . . . . . . . . . . . . . . . . . . . . 179
Creating Content with the WebPartZone . . . . . . . . . . . . . . . . . . 183
Modifying the Content with an EditorZone . . . . . . . . . . . . . 184
Adding New Items with the CatalogZone. . . . . . . . . . . . . 185
Viewing the Script behind the Controls . . . . . . . . . . . . . . 185
Keeping Data Safe with Encoding . . . . . . . . . . . . . . . . . . . 187
Defining Your Development Goals . . . . . . . . . . . 187
Part 3 • Creating Simple but Effective Pages . . . . . . . . . . 189
Chapter 7 • Creating Feedback Forms . . . . . . . . . . . . . . . . 191
Understanding the Need for Feedback Forms . . . . . . . . . . . . . . . . . . 191
Targeting Feedback Forms to Meet Specific Needs . . . . . . . . .. . . 192
Considering What You Expect from the Form . .. . . . . . . . . . 193
Defining the Basic User Requirements . . . . . . . . . . .. . . . 196
Using a Master Page to Create Multiple Feedback Form Types . . . . . . . . 197
Creating a User Satisfaction Form . . . . . . . . . . . . . . .. . . . . . . . 200
Designing User Feedback . . . . . . . . . . . . . . . . . . . . . . . . 201
Developing Automated Feedback . . . . . . . . . . . . . . . . 203
Creating a Help Request Form . . . . . . . . . . . . . . . . . . . . 203
Designing the Request Page . . . . . . . . . . . . . . . . . . . . . . . 204
Developing the XML Storage . . . . . . . . . . . . . . . . . . . . . . . . 206
Transforming the Results with XSLT . . . . . . . . . . . . . . 210
Developing a Beneficial Suggestion Form . . . . . . . . . . . . . . . . . . . . 213
Deciding between Required and Optional Data . . . 214
Devising Methods of Reducing Repeat Input . . . . . . . . . . . 215
Defining Your Development Goals . . . . . . . . . . . . . . . . . . 217
Chapter 8 • Developing a Site Search . . . . . . . . . . . . . 219
Understanding the Site Search Types . . . . . . . . . . . . . . . . . . . 220
Creating a Custom Site Search . . . . . . . . . . . . . . . . . . . . . . 220
Developing a Simple Site Search . . . . . . . . . . . . . . . . . . . . . . . . 220
Defining Preferred Links Based on Site Counters . . . . . . . . . . . . 236
Using Google to Create a Site Search . . . . . . . . . . . . . . . . . . . . 240
Performing a Simple SOAP Call . . . . . .. . . . . . . . . . . . 243
Using a Script to Call an XSLT Page . . . . . . . . . . . . . 245
Translating the Result with XSLT . . . . . . . . . . . . . . . 247
Discovering Site Maps . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249
Understanding the Differences between a Site Map and a Site Search . . . . . . 250
Using the Site Navigation Features . . . . . . . . . . . . . . . 250
Creating a Site Map . . .. . . . . . . . . . . 252
Defining Your Development Goals . . . . . . . . . . . . . . . . . . . . . . 254
Chapter 9 • Using Pop-ups and Redirection . . . . . . . . . . 255
Understanding User Concerns over Pop-ups and Redirection . . . . . . . . . . . 256
Creating a Pop-up Form . . . . . . . . . . . . . . . . . . . . . . . . 257
Using Pop-up Forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261
Additional Information . . . . . . . . . . .. . . . . . . . . . . . . 261
Help Pages . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . 269
User Survey . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . 271
Using Meta Refresh for Redirection . . . . . . . . . . . . . . . 275
Employing Server-side Redirection . . . . . . . . . . . . . . . . . 277
Understanding How Server-side Redirection Works . . . . . . . 278
Using the Coded Method . . . . . . . . . . . . . . . . . 279
Modifying the
<customErrors>
Element of the
WEB.CONFIG
File . .. . . . 280
Defining Your Development Goals . . .. . . . . . . . . . 281
Part 4 • Working with Dynamic Data . . . . . . . . . . . .. . . . . . 283
Chapter 10 • Developing Simple Database Applications . . . . . . . 285
Understanding the New SQL Server 2005 Features .. . . . . . . . . . 286
Working with SQL Server 2005 . . . . . . . . . . . . . . . . . 286
Working with SQL Computer Manager . . .. . . . . . 287
Using the SQL Server Management Studio . . . . . .. . . . . . . . . . . . . 291
Using the SQLCmd Utility . . . . . . . .. . . . . . . . . . . . . 299
Creating a Database Connection . . . . . . . . . . . . . . . . . . . . . . . . 305
Creating a Connection to SQL Server . . . . . . . . . . . . 305
Creating a Connection to Other DBMSs . . . . . . . 306
Creating a Connection to Microsoft Access Using ODBC . . . . . . . 307
Designing a Database . . . . . . . . . . . . . . . . . . . . . . . 310
Developing a SQL Server Database Using the Wizard . . . . . . . . . . . . 311
Obtaining the Northwind and Pubs Sample Databases . . . . . . . . . . 311
Relying on Code-free Data Binding . . . . . . . . . . . . . 313
Defining Your Development Goals . . . . . . . . . . . 314
Chapter 11 • Using SQL Server 2005 Efficiently . . . . . . . . . . . . . 315
Accessing the Database from Visual Studio . . .. . . . . . . . 316
Using the Server Explorer . . . . . . . . . . . . . . . . . 316
Creating Database Diagrams .. . . . . . . . . . 322
Using the Table Designer Toolbar . . . . . . . . . . . 323
Using the Data Design Toolbar . . .. . . . . . . . 325
Using the Query Designer Toolbar . . . .. . . . . . . . . 326
Creating a Blank Database . . . . . . . . . . . . . . 329
Adding the Database . . . . . . . . . . . . . 329
Designing the Tables . . . . . . . . . . . . . . . . . 331
Assigning the Relationships . . .. . . . . . . . . . . . . 333
Creating and Accessing Stored Procedures . . . . . . . 333
Working with Stored Procedures . . . . . . . . . . . . . . 333
Modifying Stored Procedures . . . . .. . . . . . . . . . 337
Creating New Stored Procedures . . .. . . . . . . . . . . . . 338
Developing Stored Procedures with .NET . . . . . . . . . . . . 352
Learning More about Stored Procedures . . . . . . . . . 353
Using Views . . . . . . . . . . . . . . . . . . . . . . . . . . . 353
Using the View Designer Toolbar . .. . . . . . . . . . . . 354
Creating a View . . . . . . . . . . . . . . . . . . . . . . . 354
Using XML Support . . . . . . . . . . .. . . . . . . . . . . . 354
Creating an XML Index . . . . . . . . . . . . . . . . . . . . . 355
Using the XML Data Toolbar . . . . . .. . . . . . . . . . . 355
Using the XML Schema Toolbar . . . . . . . . . . . . . 356
Defining an XML Schema . . . . . . . . . . . . . . . . . 357
Using the XML Control . . . . . . . . . 357
Defining Your Development Goals . . . . . . . . . . . . . . . 357
Chapter 12 • Creating an ASP.NET Crystal Reports Web Site .. . . . . . 359
Creating the RPT File . . . . . . . . . . . . . . 359
Adding the Crystal Report . . . . . . .. . . . . . . . . . . . . . . . . . . 360
Selecting the Database . . . . . . . . . .. . . . . . . . . . . . . . . . . . 360
Choosing the Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 363
Working with Field Explorer . . . . . . . . . . . . . . . . . . . . . . 369
Formatting Report Entries . . . . . . . . . . . . . . . . . . . . 371
Setting the Report Options . . . . . . . . . . . . . . . . . . . 373
Inserting and Removing Fields . . . . .. . . . . . . . . . . . . 376
Developing the Output Page . . . . . . . . . . . . . . 377
Using the CrystalReportSource Control . . . . .. . . . . . . . . 378
Using the CrystalReportViewer Control . .. . . . . 378
Defining Your Development Goals . . . . . . . . . . . . . . . . . 379
Chapter 13 • Developing Multi-tier Applications. . . . . . . . . . . . 381
Binding with Middle Tier Objects . . . . . . . . . . . . . . . . . . . . . . . . 381
Understanding the Middle Tier . . . . . . . . . . . . . . . . . . . . 383
Developing Web Service Connections . . . . . . . . . . . . . . 387
Working with Multiple Device Types . . . . . . . . . . . . . 397
Understanding WAP/WML, XHTML Mobile, and cHTML . . . . . 398
Using the ContentPager Control . . . . . . . . . . . . . . . . . 399
Working with Emulators . . .. . . . . . . . . 401
Defining Your Development Goals . . . . . . . . . . . . . . . . 402
Part 5 • Developing Full-blown Web Applications . . . . . . 403
Chapter 14 • Designing Dynamic Pages with Pizzazz . . . . . . . . . . 405
Combining Themes, Scripts, and Other Techniques . . . . . . . . . . . . 406
Avoiding Pizzazz Overkill . . . . . . . . . . . . . . . . .. . . . . . . . . . 406
Using Layout, Themes, and Code Behind Effectively . . . . . . . . . . . . . . 407
Creating Special Effects . . . . . . . . . . . . . . . . . . . 412
Mouseover with Internet Explorer and Older Browsers . . . . . . . . . . . . . . 412
Mouseover with Newer Browsers . . . . . . . . . . . . . . . 415
Presentation . . . . . . . . . . . . . . . . . . . . . . . 416
Selection Using Scripts . . . . . . . . . . . . . . . . . . . . . . . . . 420
Progressive Input Using Scripts . . . . . . . . . . . . . . . . . . . . . 422
Selection and Progressive Input with ASP.NET . . . . . . . . . . . . . 424
Understanding the Ever Changing Browser Playing Field . . . . . .. . . . . . . . 425
Creating a Dynamic Presentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 426
Using the Substitution Control . . . . . . . . . . . . . . . . . . . 426
Using the
AdRotator
Control . . . . . . . . . . . . . . . . . . . . . . . 429
Working with WebParts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 431
Dressing Up the WebParts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 431
Using the
BehaviorEditorPart
Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 433
Using the
DeclarativeCatalogPart
and
ImportCatalogPart
Controls . . . . . . . . . . . . . . . . 435
Understanding How Much Customization to Provide . . . . . . . . . . . . . . . . . . . . . . . . . 436
Working with Media . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 437
Media Uses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 437
Animated GIFs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 439
Audio . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 441
Video . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 442
Interactive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 446
Defining Your Development Goals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 447
Chapter 15 • Working with Client-side Controls . . . . . . . . . . . . . . . . . . . . . . . . . . 449
Understanding User Concerns about Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 449
Creating a Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 450
Understanding the Difference between Controls and Components . . . . . . . . . . . . . . 451
Designing a Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 451
Designing a Component . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 455
Deploying a Component or Control to the Client . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 459
Working with the ActiveX Control Test Container . . . . . . . . . . . . . . . . . . . . . . . . . . . . 460
Creating the
<Object>
Tag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 465
Working with the Microsoft Installer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 465
Signing the MSI File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 468
Registering the Component or Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 470
Setting .NET Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 472
Considering the Security Issues of Using Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 475
Using the MakeCert Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 475
Using the Certification Authority Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 476
Defining Your Development Goals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 478
Chapter 16 • Creating a Shopping Cart Application. . . . . . . . . . . . . . . . . . . . . . . . 481
Understanding the Alternatives to a Custom Application . . . . . . . . . . . . . . . . . . . . . . . . . 481
Alternative Uses of Shopping Cart Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 482
Sidestepping the Pitfalls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 483
Getting a Complete Solution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 483
Obtaining Application Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 484
Developing a Merchandizing Plan . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 484
Creating a Web Site Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 485
Presenting the Product . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 485
Developing the Product Data Flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 486
Tracking User Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 487
Getting the Payment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 487
Creating the Required Databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 489
Product Listing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 489
Customers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 490
Orders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 491
Defining Table Relationships . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 492
Designing Appropriate Management Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 492
Choosing Management Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 493
Displaying the Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 495
Changing Pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 497
Changing Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 498
Creating New Records . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 500
Updating Records . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 504
Deleting Records . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 507
Creating the Front End Pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 509
Viewing a List of Products . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 509
Displaying Product Specifics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 512
Logging the User into the System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 514
Displaying the Shopping Basket . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 516
Making the Sale . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 519
Defining Your Development Goals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 522
Part 6 • The Finishing Touches: Debug, Secure, and Distribute Your Application . . . . . . 523
Chapter 17 • Debugging Your Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 525
Understanding Why Debugging Is Important . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 525
Considering Syntax Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 526
Considering Compile Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 527
Considering Runtime Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 528
Considering Semantic Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 530
Using the Error Lookup Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 531
Locating Hidden Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 532
Using the Visual Web Developer 2005 Debugging Features . . . . . . . . . . . . . . . . . . . . . . . 534
Using the Debug Toolbar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 534
Using the Immediate Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 535
Using the Command Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 536
Using the Output Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 537
Using the Error List Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 539
Using the Locals Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 540
Using the Watch Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 542
Using the Call Stack Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 542
Managing Breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 543
Defining Your Development Goals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 544
Chapter 18 • Designing Secure Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 545
Understanding the Common Security Issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 545
Considering the Security Issues That .NET Resolves . . . . . . . . . . . . . . . . . . . . . . . . . . . 546
Determining Where .NET Can’t Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 547
Creating a Security Plan . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 552
Configuring ASP.NET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 554
Working with the Configuration Web Site . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 554
Using the Login Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 559
Checking All Incoming Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 569
An Overview of the Validators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 570
Using Validators in an Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 572
Hardening Your Applications against Outside Intrusion . . . . . . . . . . . . . . . . . . . . . . . . . . 576
Preventing Data Leaks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 576
Encrypting Your Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 577
Defining Your Development Goals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 577
Chapter 19 • Optimizing Your Applications. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 579
Working with Performance Counters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 580
Understanding Performance Counters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 580
Using Standard Performance Counters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 581
Using .NET Specific Performance Counters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 581
Creating Custom Performance Counters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 583
Defining the Custom Performance Counter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 584
Creating an
IAsyncResult
Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 589
Adding the Performance Counter to Your Application . . . . . . . . . . . . . . . . . . . . . . . . 591
Testing Your Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 591
Avoiding Performance Counter Woes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 592
Analyzing Your Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 593
Using Code Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 593
Using the Performance Wizard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 594
Defining Your Development Goals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 595
Chapter 20 • Creating Downloadable Applications . . . . . . . . . . . . . . . . . . . . . . . . 597
Considering Potential Security Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 598
Considering Client-side Setup and Configuration Issues . . . . . . . . . . . . . . . . . . . . . . . . . . 599
Using the Class Diagram (CD) File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 601
Creating Standard Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 603
Designing the Component . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 603
Adding the Component to a Web Page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 605
Creating Standard Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 607
Designing the Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 607
Adding the Control to a Web Page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 613
Using the
FileUpload
Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 616
Designing Custom SmartTags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 618
Adding Standard SmartTags to a Web Page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 619
Getting Pre-built SmartTags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 625
Developing Downloadable Application Alternatives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 626
Defining Your Development Goals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 627
Chapter 21 • Creating Accessible Pages. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 629
Reasons to Design with Accessibility in Mind . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 629
Making Controls Accessible . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 631
Adding Accessibility Attributes to Standard Controls . . . . . . . . . . . . . . . . . . . . . . . . . 632
Using Alternative Attributes to Improve Accessibility . . . . . . . . . . . . . . . . . . . . . . . . . 634
Using Alternative Tags to Improve Accessibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 635
Organizing the Web Page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 636
Working with Forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 636
Working with Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 639
Working with Graphics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 644
Using the
<NoScript>
Tag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 647
Testing Your Page for Accessibility Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 652
Using the Visual Studio Built-in Checks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 654
W3C HTML Validation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 656
Using Bobby to Test Accessibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 657
Defining Your Development Goals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 659
Part 7 • Application Development Within the Corporate Environment . . . . . . . . . . . . . . 661
Chapter 22 • Developing Interoperable Applications . . . . . . . . . . . . . . . . . . . . . . 663
Understanding the .NET/Java Development Scenario . . . . . . . . . . . . . . . . . . . . . . . . . . . . 663
An Overview of the Corporate Mixed Language Environment . . . . . . . . . . . . . . . . . . 664
Developing Reliable Mixed Language Solutions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 664
Using the Web Services Solution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 666
Using the Bridging Solution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 669
An Overview of JNBridge . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 669
Installing JNBridge . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 670
Creating a Bridged Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 670
Using the Cross-Compiler Solution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 671
An Overview of Visual MainWin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 672
Installing Visual MainWin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 672
Adding IBM WebSphere Support to Visual Studio . . . . . . . . . . . . . . . . . . . . . . . . . . . . 674
Creating the Cross-Compiled Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 675
Defining Your Development Goals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 677
Chapter 23 • Using the Team Development Tools . . . . . . . . . . . . . . . . . . . . . . . . . 679
Understanding the Visual Studio 2005 Team Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . 680
Working with Visual SourceSafe (VSS) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 682
Administering VSS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 682
Adding VSS to a Solution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 688
Working with VSS Projects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 690
Using Visual SourceSafe Explorer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 695
Working with Distributed System Designers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 696
Using the Application Connection Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 696
Using the Logical Datacenter Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 698
Using the System Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 698
Defining Your Development Goals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 700
Chapter 24 • Converting Visual Studio 2003 Applications . . . . . . . . . . . . . . . . . . 701
Understanding the Process Is One Way . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 701
Deciding Whether You Want to Make a Change . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 702
Performing the Conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 703
Understanding the Conversion Process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 704
Overcoming Potential Conversion Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 707
Considering Deprecated Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 707
Considering Difficult Conversion Issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 709
Testing the Converted Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 709
Exporting Templates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 710
Creating a Project Template . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 711
Creating an Item Template . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 713
Defining Your Development Goals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 716
Chapter 25 • Moving to Visual Studio 2005 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 717
Preserving Your Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 717
Moving the Code to IIS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 718
Creating a Solution File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 721
Fixing FrontPage Server Extension Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 722
Testing Code in the New Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 724
Compiling Your Code Using
ASPNet_Compiler.EXE
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 724
Fixing File Association Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 725
Using the ASPNet_RegIIS Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 726
Using the ASPNet_RegSQL Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 730
Defining Your Development Goals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 733
Appendices. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 735
Appendix A • A Guide to Common Development Errors . . . . . . . . . . . . . . . . . . . . 733
Plan before You Write Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 735
Avoid Performance Bottlenecks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 736
Use
Page.IsPostBack
to Control Resource Use . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 736
Perform Client-side Validation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 736
Save the View State Only When Needed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 737
Set the Session State . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 738
Use Pure HTML Whenever Possible . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 739
Keep Your Data Safe . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 739
Checking Every Input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 740
Verifying Every Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 741
Work Smarter, Not Harder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 741
Try the
HttpServerUtility.Transfer
Method . . . . . . . . . . . . . . . . . 742
Use Exceptions Carefully . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . 742
Use All Available Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 742
Rely on SQL Server Stored Procedures . . . . .. . . . . . . . . . . . . . . . 743
Precompile the Application .. . . . . . . . . . . . . . . . . . . . . . . .
g with Common Character Codes . . . . . . . . . . . . 745
Direct Replacement Using a Chart . . . . . . . . . . . . . . . . . 745
Using Direct JavaScript Code . . . . .. . . . . . . . . . . . . . . 749
Using Indirect JavaScript Code . . . .. . . . . . . . 749
Appendix C • 52 Indispensable Visual Studio Tricks and Techniques . . . . . 753
Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 759
Index . . . .. . . . . . . . . . . . . . . . . 789