| Acknowledgments | xiii |
| Introduction | xv |
| PART I INTRODUCTION TO WEB MATRIX AND ASP.NET | |
| 1 What Does Web Programming Mean, Anyway? | 3 |
| Server As Processor, Page as Program | 4 |
| Where Microsoft ASP.NET Fits In | 6 |
| Characteristics of Server-Based Web Programming | 7 |
| Postbacks and Round Trips | 8 |
| The Disconnected Web | 8 |
| Each Page Is New | 9 |
| Web Amnesia: Stateless Pages | 9 |
| Browser-Based Programming | 10 |
| Browser Compatibility | 12 |
| 2 Overview of Web Matrix, ASP.NET, and Visual Basic .NET | 15 |
| Web Programming and ASP.NET | 15 |
| A Peek Inside the .NET Framework | 17 |
| Web Matrix: Enabling Web Programming for the Rest of Us | 18 |
| Web Matrix and Community | 19 |
| Using Visual Basic .NET with Web Matrix | 20 |
| Basics of Visual Basic .NET | 23 |
| Object-Oriented Programming (OOP) | 23 |
| 3 Getting Ready to Program with ASP.NET and Web Matrix | 29 |
| Working with ASP.NET Web Pages | 29 |
| Options for Testing and Running ASP.NET Web Pages | 30 |
| Working with ISPs | 30 |
| Finding an ASP.NET-Friendly Hosting Site | 31 |
| Hosting the Site Yourself | 31 |
| Providing Data Access for Your Web Pages | 33 |
| Installing and Configuring the Required Software | 33 |
| Installing Windows | 34 |
| Setting Permissions for a Web Site | 34 |
| Installing IIS | 35 |
| Installing Internet Explorer | 35 |
| Installing the .NET Framework | 36 |
| Installing Web Matrix | 37 |
| Installing MSDE 2000 | 37 |
| PART II LEARNING THE BASICS OF PROGRAMMED WEB PAGES | |
| 4 Getting to Know Web Matrix | 43 |
| Before You Start | 43 |
| Looking Around the Web Matrix Development Environment | 46 |
| Adding Text and Controls to the Page | 49 |
| Working with Different Views of a Document | 50 |
| Positioning Text and Elements | 51 |
| Absolute Positioning | 51 |
| Controlling the Grid | 53 |
| Setting Properties for Controls | 55 |
| Programming the Button | 57 |
| Testing the Page | 57 |
| Examining How Event Handlers Work | 59 |
| Reviewing Round Trips and Postback | 61 |
| Rendering Controls | 61 |
| 5 Creating a Simple Slideshow | 65 |
| How the Slideshow Works | 65 |
| Got Pictures? | 66 |
| Creating the Page | 66 |
| Building the Slide List | 68 |
| Loading the Slide List and Initializing the Page | 69 |
| Testing the Page | 70 |
| Adding Slide Navigation | 71 |
| Maintaining the Slide Number in Viewstate | 71 |
| Programming the Next and Previous Buttons | 74 |
| Adding a Navigation Bar | 77 |
| Adding Captions to the Slideshow | 80 |
| 6 Maintaining User Preferences | 85 |
| Creating the Preferences Page | 86 |
| Populating the DropDownList Control | 88 |
| Programming the Preview Button | 91 |
| Turning Captions On and Off | 91 |
| Previewing the Current Color | 92 |
| Previewing the Font | 93 |
| Reviewing the Preview Handler | 94 |
| Testing the Preview Button | 95 |
| Saving the Preferences | 95 |
| About Cookies | 95 |
| Programming the Save Preferences Button | 96 |
| Displaying the Slideshow Page | 97 |
| Reading the Preferences | 98 |
| Reading the Cookie and Setting Values | 98 |
| Linking Back to the Preferences Page | 100 |
| Adding the Immediate Preview Feature | 101 |
| 7 Creating a Random Quotes Page | 103 |
| Creating the Quotations Text File | 104 |
| Creating the Quotations Page | 105 |
| Finding the Quotations File | 107 |
| Reading the Quotations File | 107 |
| Defensive Coding: Error Handling | 109 |
| Generating a Random Number | 110 |
| Getting and Displaying the Quotation | 111 |
| Testing the Page | 113 |
| Caching the Quotations When the Application Starts | 114 |
| 8 Creating a Page Hit Counter | 117 |
| Counting Visitors to Your Pages | 117 |
| What Is a Hit? | 119 |
| Tracking Unique Hits | 120 |
| Creating a Page That Counts Hits | 121 |
| Creating the Counter Logic | 123 |
| Getting the Current Counter | 125 |
| Checking the Cookie and Incrementing the Counter | 126 |
| Displaying the Counter | 128 |
| Testing the Counter | 130 |
| Creating Graphical Numbers | 131 |
| Creating the Graphics Files | 132 |
| Displaying the Graphical Numbers | 134 |
| PART III PROGRAMMING WEB PAGES WITH DATA | |
| 9 Show Me the Data! | 139 |
| Using Databases with Your Web Applications | 139 |
| Getting Acquainted with ASP.NET Data Access Objects | 141 |
| Understanding the Connection Object | 142 |
| Understanding the Command Object | 143 |
| Understanding the Data Reader Object | 144 |
| Preserving Data During Round Trips | 145 |
| About Data Binding | 146 |
| Creating a Database in Web Matrix | 146 |
| Creating the Database | 147 |
| Creating a Simple Data-Display Page | 153 |
| Customizing the Data-Display Grid | 155 |
| Examining Data Components in the Page | 156 |
| 10 Creating a Guestbook | 159 |
| Creating the Guestbook Database Table | 160 |
| The Guestbook Page | 163 |
| Creating Code to Add a Guestbook Entry to the Database | 164 |
| Sending the Visitor's Input to the Database | 167 |
| Creating a Simple Guestbook Listing | 170 |
| Validating User Input | 173 |
| Understanding Validator Controls | 174 |
| Adding Validation to the Guestbook | 176 |
| 11 Creating a More Flexible Guestbook Listing | 183 |
| Overview of Templates and Data Binding | 183 |
| Creating a Second Guestbook Listing Page | 187 |
| Binding Controls | 191 |
| Defining Additional Templates | 194 |
| Programming the DataList Control | 195 |
| Testing the Page | 196 |
| Adding an Alternating Template | 197 |
| Examining Templates in HTML View | 198 |
| Examining Data Binding | 199 |
| Working with the Repeater Control | 201 |
| 12 Creating a Database-Driven Slideshow | 205 |
| Collecting Pictures for the Slideshow | 206 |
| The Slideshow Database Structure | 207 |
| Creating the Slideshow Tables | 209 |
| Creating a Slideshow Picker Page | 212 |
| Programming the Slideshow Picker Page | 214 |
| Data and State Management | 216 |
| Understanding Datasets | 217 |
| Caching Data in the Session Object | 218 |
| Creating the Slideshow Viewer Page | 219 |
| Programming the Slideshow Viewer Page | 221 |
| Programming the Dataset | 222 |
| Displaying the Current Slide | 226 |
| Navigating Between Slides | 228 |
| Testing the Slideshow Viewer Page | 229 |
| 13 Updating Master-Details Tables | 231 |
| Creating the Slideshows Master Page | 232 |
| Inserting Slideshow Records into the Database | 235 |
| Navigating to the Details Page | 238 |
| Creating the Slide Details Page | 240 |
| Reading the Slideshow Name from the Master Page | 242 |
| Inserting Individual Slides into the Database | 243 |
| Displaying Slides for the Current Slideshow | 245 |
| Deleting Existing Slides | 248 |
| Editing Existing Slides | 250 |
| Programming the Edit Buttons to Update the Database | 252 |
| Testing Editing Capabilities | 255 |
| Maintaining Master-Details Integrity | 256 |
| 14 Creating a Web-Based Calendar | 259 |
| Creating the Calendar Database Table | 260 |
| Creating a Calendar Entry Page | 261 |
| Programming Date Selection with the Calendar | 264 |
| Adding a Calendar Record to the Database | 265 |
| Creating a Page to View the Calendar | 268 |
| Highlighting Appointment Days in the Calendar | 269 |
| Displaying Appointment Details | 272 |
| 15 Sending E-Mail Messages from Your Web Application | 277 |
| Configuring an E-Mail Server | 278 |
| How the SMTP Virtual Server Works | 278 |
| Installing and Configuring the SMTP Virtual Server | 279 |
| Creating a Simple Page to Send E-Mail Messages | 285 |
| Creating Code to Send E-Mail Messages | 288 |
| Sending E-Mail Alerts from Your Guestbook | 291 |
| Allowing Users to E-Mail Pictures from Your Slideshows | 294 |
| Adding a Send This Picture Button to the Slideshow | 295 |
| Creating a Page for Sending the Picture | 296 |
| Adding Code to Display the Picture | 298 |
| Adding Code to Send the Picture as an E-Mail Attachment | 299 |
| Testing the Send Picture Page | 300 |
| PART IV APPENDIXES | |
| A Security and ASP.NET Web Applications | 305 |
| Protecting Your Computer | 307 |
| Restricting Access to Your Computer | 307 |
| Restricting Access to Resources on the Computer | 308 |
| Staying on Top of Security | 309 |
| General Recommendations | 310 |
| Securing Your Web Applications | 310 |
| Understanding the ASPNET Account | 310 |
| Protecting Against Malicious User Input | 312 |
| Guarding Secrets | 314 |
| Authenticating Users | 315 |
| Accessing Databases Securely | 317 |
| Thinking Securely | 320 |
| B Deploying Web Matrix Applications | 321 |
| Deploying Web Pages on a Local Web Site | 321 |
| Configuring IIS for a Local Web Site | 322 |
| Configuring Database Access for a Local Web Site | 324 |
| Deploying Web Pages to a Hosting Site | 325 |
| Copying Web Pages to a Hosting Site | 325 |
| Copying Database Tables to a Hosting Site | 328 |
| GLOSSARY | 337 |
| INDEX | 345 |