Wiley.com
Print this page Share

Beginning ASP.NET 3.5: In C# and VB

ISBN: 978-0-470-18759-3
Paperback
768 pages
March 2008
Beginning ASP.NET 3.5: In C# and VB (047018759X) cover image
This title is out-of-print and not currently available for purchase from this site.

Acknowledgments xi

Introduction xxiii

Chapter 1: Getting Started with ASP.NET 3.5 1

Microsoft Visual Web Developer 2

Getting Visual Web Developer 3

Installing Visual Web Developer Express Edition 3

Creating Your First ASP.NET 3.5 Web Site 5

An Introduction to ASP.NET 3.5 9

Understanding HTML 10

A First Look at ASP.NET Markup 14

A Tour of the IDE 15

The Main Development Area 15

Informational Windows 21

Customizing the IDE 22

Rearranging Windows 22

Modifying the Toolbox 23

Customizing the Document Window 25

Customizing Toolbars 25

Customizing Keyboard Shortcuts 26

Resetting Your Changes 27

The Sample Application 28

Practical Tips on Visual Web Developer 30

Summary 30

Exercises 31

Chapter 2: Building an ASP.NET Web Site 33

Creating Web Sites with VWD 2008 34

Different Project Types 34

Choosing the Right Web Site Template 35

Creating and Opening a New Web Site 36

Working with Files in Your Web Site 39

The Many File Types of an ASP.NET 3.5 Web Site 39

Adding Existing Files 43

Organizing Your Site 44

Special File Types 46

Working with Web Forms 47

The Different Views on Web Forms 47

Choosing between Code Behind and Pages with Inline Code 48

Adding Markup to Your Page 53

Connecting Pages 59

Practical Tips on Working with Web Forms 61

Summary 61

Exercises 62

Chapter 3: Designing Your Web Pages 63

Why Do You Need CSS? 63

Problems of HTML Formatting 64

How CSS Fixes Formatting Problems 65

An Introduction to CSS 65

CSS — The Language 69

The Style Sheet 69

Adding CSS to Your Pages 80

Working with CSS in Visual Web Developer 82

Creating New Styles in External Style Sheets 83

Creating Embedded and Inline Style Sheets 88

Applying Styles 94

Managing Styles 96

Practical Tips on Working with CSS 99

Summary 100

Exercises 100

Chapter 4: Working with ASP.NET Controls 103

Introduction to Server Controls 103

A Closer Look at ASP.NET Server Controls 107

Defining Controls in Your Pages 108

Common Properties for All Controls 108

Types of Controls 110

Standard Controls 111

HTML Controls 124

Data Controls 124

Validation Controls 125

Navigation Controls 125

Login Controls 125

Ajax Extensions 125

WebParts 125

The ASP.NET State Engine 126

What Is State and Why Is It Important? 126

How the State Engine Works 127

Not All Controls Rely on ViewState 131

A Note About ViewState and Performance 131

Practical Tips on Working with Controls 132

Summary 132

Exercises 133

Chapter 5: Programming Your ASP.NET Web Pages 135

Introduction to Programming 136

Data Types and Variables 136

Converting Data Types 140

Using Arrays and Collections 142

Statements 146

Operators 147

Making Decisions 154

Loops 161

Organizing Code 164

Methods: Functions and Subroutines 165

The App_Code Folder 167

Organizing Code with Namespaces 171

Writing Comments 173

Object Orientation Basics 176

Important OO Terminology 176

Events 188

Practical Tips on Programming 189

Summary 190

Exercises 191

Chapter 6: Creating Consistent Looking Web Sites 193

Consistent Page Layout with Master Pages 194

Creating Master Pages 196

Creating Content Pages 198

Using a Centralized Base Page 203

An Introduction to the ASP.NET Page Life Cycle 204

Implementing the Base Page 206

Creating Reusable Page Templates 210

Themes 214

Different Types of Themes 215

Choosing Between Theme and StyleSheetTheme 215

Applying Themes 215

Extending Themes 219

Dynamically Switching Themes 222

Skins 228

Creating a Skin File 229

Named Skins 231

A Final Note on Skins 232

Practical Tips on Creating Consistent Pages 232

Summary 233

Exercises 234

Chapter 7: Navigation 235

Different Ways to Move around Your Site 236

Understanding Absolute and Relative URLs 236

Understanding Default Documents 240

Using the Navigation Controls 241

Architecture of the Navigation Controls 242

Examining the Web.sitemap File 242

Using the Menu Control 244

Using the TreeView Control 253

Using the SiteMapPath Control 257

Programmatic Redirection 259

Programmatically Redirecting the Client to a Different Page 259

Server-Side Redirects 261

Practical Tips on Navigation 264

Summary 264

Exercises 265

Chapter 8: User Controls 267

Introduction to User Controls 267

Creating User Controls 268

Adding User Controls to a Content Page or Master Page 271

Site-Wide Registration of User Controls 274

User Control Caveats 275

Adding Logic to Your User Controls 277

Creating Your Own Data Types for Properties 277

Implementing ViewState Properties 283

ViewState Considerations 288

Practical Tips on User Controls 289

Summary 289

Exercises 290

Chapter 9: Validating User Input 291

Gathering Data from the User 292

Validating User Input in Web Forms 293

Processing Data at the Server 307

Sending E-mail from Your Web Site 307

Reading from Text Files 313

Practical Tips on Validating Data 318

Summary 318

Exercises 319

Chapter 10: ASP.NET AJAX 321

Introducing Ajax 322

Using ASP.NET AJAX in Your Projects 323

Creating Flicker-Free Pages 323

Providing Feedback to Users 328

Using the Timer Control 332

Using Web Services in Ajax Web Sites 337

What Are Web Services? 337

Creating Web Services 338

Using Web Services in Your Ajax Web Site 342

This Is Just the Beginning 349

Practical Ajax Tips 349

Summary 350

Exercises 351

Chapter 11: Introduction to Databases 353

What Is a Database? 354

Different Kinds of Relational Databases 355

Using SQL to Work with Database Data 355

Retrieving and Manipulating Data 358

Creating Your Own Tables 371

Data Types in SQL Server 371

Understanding Primary Keys and Identities 373

Creating Relationships Between Tables 377

Practical Database Tips 380

Summary 381

Exercises 381

Chapter 12: Displaying and Updating Data 383

Data Controls 383

Data-Bound Controls 384

Data Source Controls 386

Data Source and Data-Bound Controls Working Together 386

Displaying and Editing Data with GridView 386

Inserting Data with DetailsView 392

Storing Your Connection Strings in web.config 395

Filtering Data 397

Customizing the Appearance of the Data Controls 403

Configuring Columns or Fields of Data-Bound Controls 403

Updating and Inserting Data 409

Using DetailsView to Insert and Update Data 409

Practical Tips for Displaying and Updating Data 422

Summary 423

Exercises 423

Chapter 13: LINQ 425

Introducing LINQ 426

Different Types of LINQ 427

Introducing LINQ to SQL 427

Mapping Your Data Model to an Object Model 428

Introducing Query Syntax 433

Standard Query Operators 433

Shaping Data with Anonymous Types 437

Using Server Controls with LINQ Queries 443

New Controls Introduced in ASP.NET 3.5 443

A Few Notes about Performance 471

Practical LINQ Tips 472

Summary 472

Exercises 473

Chapter 14: Presenting Data — Advanced Topics 475

Formatting Your Controls Using Styles 476

An Introduction to Styles 477

Combining Styles, Themes, and Skins 481

Handling Events 485

The ASP.NET Page and Controls Life Cycles Revisited 485

Handling Errors that Occur in the Data Source Controls 498

Caching 502

Common Pitfalls with Caching Data 503

Different Ways to Cache Data in ASP.NET Web Applications 505

Practical Data Tips 513

Summary 514

Exercises 515

Chapter 15: Security in Your ASP.NET 3.5 Web Site 517

Introducing Security 518

Identity: Who Are You? 518

Authentication: How Can You Prove Who You Are? 518

Authorization: What Are You Allowed to Do? 518

An Introduction to the ASP.NET Application Services 519

Introducing the Login Controls 520

The Login Controls 525

Configuring Your Web Application 537

The Role Manager 541

Configuring the Role Manager 541

Managing Users with the WSAT 542

Configuring the Web Application to Work with Roles 546

Programmatically Checking Roles 551

Practical Security Tips 554

Summary 555

Exercises 555

Chapter 16: Personalizing Web Sites 557

Understanding Profile 558

Configuring the Profile 558

Using the Profile 565

Other Ways of Dealing with Profile 583

Anonymous Identification 583

Cleaning Up Old Anonymous Profiles 584

Looking at Other Users’ Profiles 585

Practical Personalization Tips 589

Summary 589

Exercises 590

Chapter 17: Exception Handling, Debugging, and Tracing 591

Exception Handling 592

Different Types of Errors 592

Catching and Handling Exceptions 594

Global Error Handling and Custom Error Pages 601

The Basics of Debugging 607

Tools Support for Debugging 611

Moving around in Debugged Code 611

Debugging Windows 612

Debugging Client-Side Script 618

Tracing Your ASP.NET Web Pages 621

Using the Standard Tracing Capabilities 622

Adding Your Own Information to the Trace 626

Tracing and Performance 628

A Security Warning 628

Practical Debugging Tips 628

Summary 629

Exercises 630

Chapter 18: Deploying Your Web Site 631

Preparing Your Web Site for Deployment 632

Avoiding Hardcoded Settings 632

Copying Your Web Site 639

Creating a Simple Copy of Your Web Site 639

Publishing Your Web Site 642

Running Your Site under IIS 643

Installing and Configuring the Web Server 643

Understanding Security in IIS 651

NTFS Settings for Planet Wrox 652

Troubleshooting Web Server Errors 656

Moving Data to a Remote Server 657

Using the Database Publishing Wizard 658

Recreating the Database 660

The Deployment Checklist 661

What’s Next 662

Summary 663

Exercises 664

Appendix A: Exercise Answers 665

Appendix B: Configuring SQL Server 2005 687

Configuring SQL Server 2005 687

Terminology and Concepts 688

Using SQL Server Management Studio 689

Enabling Remote Connections in SQL Server 690

Connecting Your Application to SQL Server 2005 693

Configuring Application Services 701

Configuring Your Database for the Application Services 702

Overriding the LocalSqlServer Connection String 703

Overriding the Settings of the Application Services 704

Index 707

Back to Top