Skip to main content

Beginning ASP.NET 2.0 with C#

Beginning ASP.NET 2.0 with C#

Chris Hart, John Kauffman, David Sussman, Chris Ullman

ISBN: 978-0-470-05276-1

Apr 2006

735 pages

Description

ASP.NET 2.0 is an amazing technology that allows you to develop web sites and applications with very little hassle, and its power and depth enable it to host even the most complex applications available. Using code examples in C#, this invaluable beginner's guide shows you how to program web applications in ASP.NET 2.0 and see dynamic results with minimal effort.

Through detailed explanations and working C# code examples, this popular author team eases you into the world of ASP.NET development and gradually introduces you to all sorts of interesting ASP.NET tricks and tools. You'll quickly see how ASP.NET 2.0 is designed to ensure a significant reduction in the amount of code you have to write--and, in turn, to make your life easier.

What you will learn from this book

  • Why Visual Web Developer is an ideal environment for building feature-rich ASP.NET 2.0 applications with C#
  • How to secure web sites, providing login functionality and role-based access to content
  • Useful techniques for safely updating data, using ASP.NET 2.0's built-in data handling capabilities
  • How centralized site design can be easily achieved
  • How to add e-commerce functionality to a site
  • Methods for enhancing an application's performance

Who this book is for

This book is for anyone new to web programming who wants to program dynamic, feature-rich web applications in ASP.NET 2.0. It will also be ideal for programmers seeking to upgrade their ASP 3 knowledge to ASP.NET, or programmers from non-Microsoft web disciplines who need to learn ASP.NET 2.0.

Wrox Beginning guides are crafted to make learning programming languages and technologies easier than you think, providing a structured, tutorial format that will guide you through all the techniques involved.

Acknowledgments.

Introduction.

Chapter 1: An Introduction to ASP.NET 2.0 and the Wrox United Application.

The Site You Will Build.

ASP.NET 2.0—A Powerful Tool to Build Dynamic Web Sites.

Simple Solutions for Common Web Site Tasks.

Where Does ASP.NET 2.0 Fit with Other Technology?

Exploring the Wrox United Application.

Getting Started with Your Wrox United Site.

VWD Express—A Development Environment.

Summary.

Exercises.

Chapter 2: Site Design.

General Design Objectives.

Master and Content Pages.

Additional Capabilities of Master Pages.

Creating a Site Map.

General Guidelines for Site Design.

Standard Files for ASP.NET 2.0 Applications.

Troubleshooting Site Design Errors.

Summary.

Exercises.

Chapter 3: Page Design.

Static Page Design.

The World of HTML.

Dynamic Content.

Introduction to Server Controls.

Types of Server Controls.

Summary.

Exercises.

Chapter 4: Membership and Identity.

Security Basics.

ASP.NET Security.

Wrox United Security.

Summary.

Exercises.

Chapter 5: Styling with Themes.

Styling a Site.

Themes in Wrox United.

Styling and Layout Best Practices.

Summary.

Exercises.

Chapter 6: Events and Code.

Web Server Architecture.

Server-Side Events.

Adding Events to the Page.

Events Aren’t Triggered by Users Only.

Indirect Events.

Canceling Events.

Global Events.

Summary.

Exercises.

Chapter 7: Reading Data.

Introducing Databases.

Using ASP.NET 2.0’s Data Controls.

Data Source Controls.

Data-Bound Controls.

Data Source Controls with Parameters.

Multiple Data Controls Working Together.

Working with XML Data.

Binding Syntax.

Summary.

Exercises.

Chapter 8: Writing Data.

Introduction to Writing Data.

Changing Existing Records.

Adding New Records.

Deleting Records.

Uploading Pictures.

Improving the Upload of Pictures.

Summary.

Exercises.

Chapter 9: Code.

Variables and Data Types.

Statements.

Namespaces.

Working with Classes.

Variable Scope and Lifetime.

Generics.

Summary.

Exercises.

Chapter 10: Componentization.

The Separation of Code from Content.

The Separation of Code from Design.

Code-Behind.

Creating a Code-Behind File.

Data Layers.

User Controls.

Composite Controls.

Assemblies and Custom Server Controls.

Summary.

Exercises.

Chapter 11: Roles and Profiles.

The Importance of Roles.

Introducing Roles in Wrox United.

Configuring Page-Level Authorization.

Working with Roles in Code.

Enabling User Profiles.

Building a Profile.

Managing Anonymous Shopping Carts.

Summary.

Exercises.

Chapter 12: Web Services.

Looking at Web Services.

The Life Cycle of a Web Service.

The Structure of Your Web Service.

Creating a Web Service.

Testing Your Web Service.

Web Service Discovery.

Adding the Fixture Service to Your Application.

Putting It All Together.

Remote Web Services—PocketPC Application.

Web Service Security.

Summary.

Exercises.

Chapter 13: E-Commerce.

The E-Commerce Pipeline.

The Product Catalog.

The Shopping Cart.

Checkout.

Secure Transactions.

What Else Can You Do?

Summary.

Exercises.

Chapter 14: Performance.

Simple Techniques.

Pages and Code.

Caching.

Designing for Performance.

Testing Performance.

Summary.

Exercises.

Chapter 15: Dealing with Errors.

Defensive Coding.

Exception Handling.

Exceptions Best Practices.

Global Exception Handling.

Custom Error Pages.

Debugging and Tracing.

Summary.

Exercises.

Chapter 16: Deployment, Builds, and Finishing Up.

Site Deployment.

Testing and Maintenance.

Where to Now?

References.

Summary.

Exercise.

Appendix A: Exercise Answers.

Appendix B: Setup.

System Requirements.

Visual Web Developer Express Installation.

Web Site Folder Setup.

Wrox United Installation.

Troubleshooting.

Appendix C: Wrox United Database Design.

Standalone Tables.

Wrox United Store Tables.

Appendix D: VWD Database Explorer.

Opening the Database Explorer.

Adding an Existing Database to the Database Explorer.

Viewing Database Diagrams.

Exploring a Table’s Structure.

Observing and Editing Data of Existing Tables.

Creating a New Database.

Creating a New Table and Adding Data.

Examining and Creating Views.

Examining a Stored Procedure (SPROC).

Summary.

Appendix E: CSS and HTML Quick Reference.

Styling Pages and Controls.

CSS Reference.

Common HTML Tags by Category.

HTML Common Attributes to the CSS Property.

Recommended Reading.

Index.

Code Downloads
Code downloads for this title are available here.
Complete Code Download

This single 43Mb zip file contains all the code to download for the start and end files for each chapter as well as the complete WroxUnited application.

Please read appendix B to understand where to install this code.

Download
WroxUnited Application
Download just the complete, final C# version of the WroxUnited application.
Download
WroxUnited Application Ch07
Chapter 7 start database replacement
Download
Chapter 1 Code
Download the code for Chapter 1 only.
Download
Chapter 2 Code
Download the code for Chapter 2 only.
Download
Chapter 3 Code
Download the code for Chapter 3 only.
Download
Chapter 4 Code
Download the code for Chapter 4 only.
Download
Chapter 5 Code
Download the code for Chapter 5 only.
Download
Chapter 6 Code
Download the code for Chapter 6 only.
Download
Chapter 7 Code
Download the code for Chapter 7 only.
Download
Chapter 8 Code
Download the code for Chapter 8 only.
Download
Chapter 9 Code
Download the code for Chapter 9 only.
Download
Chapter 10 Code
Download the code for Chapter 10 only.
Download
Chapter 11 Code
Download the code for Chapter 11 only.
Download
Chapter 12 Code
Download the code for Chapter 12 only.
Download
Chapter 13 Code
Download the code for Chapter 13 only.
Download
Chapter 14 Code
Download the code for Chapter 14 only.
Download
Chapter 15 Code
Download the code for Chapter 15 only.
Download
Chapter 16 Code
Download the code for Chapter 16 only.
Download
ChapterPageDetailsDatePrint Run
115Error in Text
Add Folder

should be:
New Folder
11/10/06

9296Error in Code
shaded code line at bottom of page:
Label1.Text = Convert.ToInt32(TextBox1.Text) + Convert.ToInt32(TextBox.Text);
should be:
Label1.Text = (Convert.ToInt32(TextBox1.Text) +
Convert.ToInt32(TextBox2.Text)).ToString();
8/31/06

9299Error in Code
first shaded code line:
string[,] MyArray = new string[3, 3];

should be:
string[,] MyArray = new string[4, 4];
8/31/06

9299Error in Code
2nd shaded code line
string[, ,] MyArray2 = new string[3, 3, 3];

should be:
string[, ,] MyArray2 = new string[4, 4, 4];
8/31/06

322Error in Code
beginning with the 14 line:
while (rdr.Read())
{
goalsFor += Convert.ToInt32(rdr["GoalsFor"]);
goalsAgainst += Convert.ToInt32(rdr["GoalsAgainst"]);

if (goalsFor > goalsAgainst)
wins++;
else if (goalsFor < goalsAgainst)
losses++;
else
draws++;
}

SHOULD all be replaced by:
while (rdr.Read())
{
int thisGameGoalsFor = Convert.ToInt32(rdr["GoalsFor"]);
int thisGameGoalsAgainst = Convert.ToInt32(rdr["GoalsAgainst"]);

if (thisGameGoalsFor > thisGameGoalsAgainst)
wins++;
else if (thisGameGoalsFor < thisGameGoalsAgainst)
losses++;
else
draws++;

goalsFor += thisGameGoalsFor;
goalsAgainst += thisGameGoalsAgainst;
}
8/31/06

322Error in Code
next to last code line:
winRatio = Convert.ToInt32(wins / losses * 10);

should be:
double winPercent = wins * 1.0 / losses;
winRatio = Convert.ToInt32(winPercent * 10);
8/31/06

336Error in Code
2nd code block 5th line AND 3rd code block 5th line:
_Productname

shoule be:
_productName
8/31/06

337Error in Heading
heading:
Shared Methods and Properties
should be:
Static Methods and Properties
8/31/06

337Error in Text
paragraph before last code line:
Shared keyword

should be:
static keyword
8/31/06

337Error in Code
last code line:
Utils.Log("An exception occurred");

should be:
Tools.Log("An exception occurred");
8/31/06

12445Note
UDDI:
Microsoft, IBM, and others have all closed their public UDDI registries. You should consider this public registry technology obsolete.
08/29/2007

658Inaccurate Information
On page 658 in the WROX United Installation section, it says:
"Go to www.wrox.com and search for dedicated page for Beginning ASP.NET 2.0 with C++."

It should say:
"Go to www.wrox.com and search for dedicated page for Beginning ASP.NET 2.0 with C#."
07/09/2006

662Error in Text
page 662, the start of the second paragraph under "Checking the Installation with IIS":

Text reads:
Please note that while Figure B-22 is seemingly identical to Figure B-21, the Address line reveals a small difference.

Should be:
Please note that while Figure B-24 is seemingly identical to Figure B-23, the Address line reveals a small difference.
08/10/2006