Table of Contents
Preface ..................................................................................................... xi
1. Introducing ASP.NET and the .NET Platform ........................................... 1
What is ASP.NET? ............................................................................... 2
Installing the Required Software ........................................................... 5
Installing the Web Server ............................................................. 6
Installing the .NET Framework and the SDK ................................ 9
Configuring the Web Server ....................................................... 11
Installing SQL Server 2005 Express Edition ................................ 22
Installing SQL Server Management Studio Express ..................... 22
Installing Visual Web Developer 2005 ........................................ 25
Writing your First ASP.NET Page ....................................................... 26
Getting Help ...................................................................................... 32
Summary ........................................................................................... 32
2. ASP.NET Basics .................................................................................... 33
ASP.NET Page Structure .................................................................... 34
Directives .................................................................................. 36
Code Declaration Blocks ............................................................ 37
Code Render Blocks ................................................................... 39
ASP.NET Server Controls ........................................................... 40
Server-side Comments ................................................................ 41
Literal Text and HTML Tags ....................................................... 42
View State ......................................................................................... 44
Working with Directives ..................................................................... 47
ASP.NET Languages ........................................................................... 48
Visual Basic ............................................................................... 48
C# ............................................................................................. 49
Summary ........................................................................................... 49
3. VB and C# Programming Basics ............................................................ 51
Programming Basics ........................................................................... 51
Control Events and Subroutines ................................................. 52
Page Events ................................................................................ 56
Variables and Variable Declaration .............................................. 59
Arrays ........................................................................................ 62
Functions ................................................................................... 65
Operators ................................................................................... 68
Conditional Logic ...................................................................... 70
Loops ........................................................................................ 72
Object Oriented Programming Concepts ............................................. 76
Objects and Classes .................................................................... 77
Properties .................................................................................. 81
Methods .................................................................................... 82
Classes ....................................................................................... 82
Constructors .............................................................................. 82
Scope ......................................................................................... 83
Events ........................................................................................ 84
Understanding Inheritance ......................................................... 84
Objects In .NET ......................................................................... 85
Namespaces ............................................................................... 87
Using Code-behind Files ..................................................................... 88
Summary ........................................................................................... 92
4. Constructing ASP.NET Web Pages ......................................................... 93
Web Forms ........................................................................................ 94
HTML Server Controls ...................................................................... 95
Using the HTML Server Controls ............................................... 97
Web Server Controls ........................................................................ 101
Standard Web Server Controls ................................................. 103
List Controls ............................................................................ 110
Advanced Controls ................................................................... 112
Web User Controls ........................................................................... 126
Creating a Web User Control ................................................... 126
Master Pages .................................................................................... 132
Using Cascading Style Sheets (CSS) ................................................. 135
Types of Styles and Style Sheets ............................................... 136
Summary ......................................................................................... 141
5. Building Web Applications ................................................................. 143
Introducing the Dorknozzle Project .................................................. 144
Using Visual Web Developer ............................................................ 147
Meeting the Features ................................................................ 148
Executing your Project ...................................................................... 156
Using Visual Web Developers Built-in Web Server ................... 157
Using IIS ................................................................................. 160
Core Web Application Features ........................................................ 166
Web.config ............................................................................... 166
Global.asax .............................................................................. 170
Using Application State ........................................................... 173
Working with User Sessions ..................................................... 180
Using the Cache Object ............................................................ 182
iv
Build Your Own ASP.NET 2.0 Web Site Using C# & VB
Using Cookies .......................................................................... 183
Starting the Dorknozzle Project ........................................................ 186
Preparing the Sitemap .............................................................. 187
Using Themes, Skins, and Styles .............................................. 189
Building the Master Page .......................................................... 195
Using the Master Page .............................................................. 199
Extending Dorknozzle ...................................................................... 201
Debugging and Error Handling ......................................................... 204
Debugging with Visual Web Developer ..................................... 204
Other Kinds of Errors ............................................................... 210
Custom Errors .......................................................................... 212
Handling Exceptions Locally .................................................... 213
Summary ......................................................................................... 218
6. Using the Validation Controls ............................................................. 219
Introducing the ASP.NET Validation Controls .................................. 220
Enforcing Validation on the Server ........................................... 223
Using Validation Controls ................................................................ 229
RequiredFieldValidator ............................................................. 230
CompareValidator .................................................................... 231
RangeValidator ......................................................................... 233
ValidationSummary ................................................................. 235
RegularExpressionValidator ...................................................... 236
CustomValidator ...................................................................... 239
Validation Groups ............................................................................ 242
Updating Dorknozzle ....................................................................... 245
Summary ......................................................................................... 250
7. Database Design and Development .................................................... 251
What is a Database? ........................................................................ 252
Creating your First Database ............................................................ 254
Creating a New Database Using Visual Web Developer ............. 255
Creating a New Database Using SQL Server Management Stu-
dio ........................................................................................... 256
Creating Database Tables ................................................................. 258
Data Types ............................................................................... 262
Column Properties ................................................................... 264
Primary Keys ........................................................................... 265
Creating the Employees Table ................................................... 267
Creating the Remaining Tables ................................................. 271
Populating the Data Tables ....................................................... 272
Relational Database Design Concepts ............................................... 276
v
Foreign Keys ............................................................................ 278
Using Database Diagrams ........................................................ 280
Implementing Relationships in the Dorknozzle Database .......... 284
Diagrams and Table Relationships ............................................ 287
Summary ......................................................................................... 292
8. Speaking SQL ..................................................................................... 293
Reading Data from a Single Table ..................................................... 294
Using the SELECT Statement ..................................................... 297
Selecting Certain Fields ............................................................ 299
Selecting Unique Data with DISTINCT ...................................... 300
Row Filtering with WHERE .......................................................... 302
Selecting Ranges of Values with BETWEEN .................................. 303
Matching Patterns with LIKE .................................................... 304
Using the IN Operator .............................................................. 305
Sorting Results Using ORDER BY ................................................ 306
Limiting the Number of Results with TOP ................................. 307
Reading Data from Multiple Tables .................................................. 307
Subqueries ............................................................................... 308
Table Joins ............................................................................... 309
Expressions and Operators ............................................................... 310
Transact-SQL Functions ................................................................... 313
Arithmetic Functions ................................................................ 314
String Functions ....................................................................... 315
Date and Time Functions ......................................................... 317
Working with Groups of Values ........................................................ 318
The COUNT Function ................................................................. 319
Grouping Records Using GROUP BY ........................................... 319
Filtering Groups Using HAVING ................................................. 321
The SUM, AVG, MIN, and MAX Functions ....................................... 322
Updating Existing Data .................................................................... 322
The INSERT Statement ............................................................. 323
The UPDATE Statement ............................................................. 324
The DELETE Statement ............................................................. 325
Stored Procedures ............................................................................ 326
Summary ......................................................................................... 330
9. ADO.NET ........................................................................................... 331
Introducing ADO.NET ..................................................................... 332
Importing the SqlClient Namespace ....................................... 333
Defining the Database Connection ........................................... 334
Preparing the Command .......................................................... 336
vi
Build Your Own ASP.NET 2.0 Web Site Using C# & VB

Get Build Your Own ASP.NET 2.0 Web Site Using C# & VB, Second Edition 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.