Skip to main content

Beginning ASP.NET 3.5: In C# and VB

Beginning ASP.NET 3.5: In C# and VB

Imar Spaanjaars

ISBN: 978-0-470-18759-3

Mar 2008

768 pages

Select type: Paperback

Product not available for purchase

Description

This book is for anyone who wants to learn how to build rich and interactive Microsoft ASP.NET web sites. With the knowledge you gain from this book, you create a great foundation to build any type of web site, ranging from simple hobby-related web sites to sites you may be creating for commercial purposes. Using this book’s step-by-step format you’ll learn to:

  • Obtain, install, and customize Visual Web Developer (VWD) 2008
  • create a new web site and how to add new pages to it.
  • use the numerous tools in VWD to create HTML and ASP.NET pages
  • use the VWD tools and  CSS, the language that is used to format web pages
  • What ASP.NET server controls are, what they are used for, and how to use them
  • program web pages Visual Basic or C#
  • create consistent-looking pages through the use of master pages, skins, and themes
  • build the navigation structure of your site
  • create and use User Controls and enhance them to repeat content like menus and banners
  • accept, validate, and process user input and send e-mail from your ASP.NET web application
  • create good looking, flicker free web page interaction with ASP.NET Ajax
  • the basics of SQL, the language used access and alter data in a database
  • use the database tools found in Visual Web Developer
  • use the ASP.NET data controls to create an interface for your users to interact with your application’s data
  • use LINQ to SQL to access SQL Server databases without writing a lot of manual code
  • change the visual appearance of your data through the use of control styles
  • interact with the data-bound controls and speed up your application
  • use the security ASP.NET features to create user accounts, distinguish between anonymous and logged on users, and manage the users in your system
  • create personalized web pages with content targeted at individual users
  • find and fix problems with VWD debugging tools
  • deploy and run your final web 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

C# code
This single file contains the combined contents of all chapter downloads in C#.
Download
VB code
This single file contains the combined contents of all chapter downloads in VB.
Download
ChapterPageDetailsDatePrint Run
XXVIIIError in Text
but look for a feature like User Folder Names

should be:

but look for a feature like Use Folder Names
07/15/2008

16Error in Text
first paragraph:

reads: "At the top of the application, right below the Windows title bar..."

Should be: "At the top of the application, right below the window's title bar..."
2/25/11

24Error in Text
Reads: Note that VWD automatically inserts the closing < h1 > for you.

It should read: Note that VWD automatically inserts the closing < /h1 > for you.
10/15/2010

233Error in Text
Last list in the "...this chapter examines:", reads:

"How to use the designer tools to created formatted web pages"

should read:

"How to use the designer tools to create formatted web pages"
07/08/2008

41Error in Table
Last item in the table, last column:

Contains design information for controls in your web site. Skins are discussed in the next chapter.

Should be

Contains design information for controls in your web site. Skins are discussed in Chapter 6.
03/05.09

43Typo in Text
The last sentence on the page (item 5):

"... the CSS file will be added to you site."

Should be

"... the CSS file will be added to your site."
1/29/09

257Error in Text
and not the entire table with four rows

Should be:

and not the entire table with three rows
07/15/2008

88Error in Text
?blue?

should be:

?green?
07/15/2008

3100Typo in Text
"The heading must have a font size if 18 pixels"

should read:

"The heading must have a font size of 18 pixels"
12/30/08

4120Error in Code interpretation
step 6, 3rd shaded line the part that says: lstFavoriteLanguage Please note that the first character is a lower case L, not the number one. The code is correct as is with that character as a lower case L.
04/03/08

4133Error in Text
end of 2nd paragraph:
"which controls attribute to?

Should be:
"which controls contribute to"
09/22/08

5141Error in Code
Gray box near the top of the page, final line:

Dim i4 as Integer = CType(o2, Integer) 'Works, because 02 <i>looks</i> like an Integer

should be:

Dim i4 as Integer = CType(o2, Integer) 'Works, because o2 <i>looks</i> like an Integer
12/16/08

162Error in Text
single sentence paragraph near the middle of the page:
The C# example doesn't extract 1 from the Length, though.

Should be:
The C# example doesn't subtract 1 from the Length, though.
09/07/08

5165Typo in Text
Below C# block:

...to what extend other web pages...

Should be:

...to what extent other web pages...
4/20/09

5173Error in Text
Public Partial Class Demos_Calculator

Should be

Partial Public Class Demos_Calculator
03/05/09

5173, 177Error in Code
The Calculator type on the left side of the assignment operator on the top of page 173 is missing the namespace prefix. Change this:

Calculator myCalculator = new Wrox.Samples.Calculator();

to this:

Wrox.Samples.Calculator = new Wrox.Samples.Calculator()
4/20/09

5177Error in Text
First C# example shows a space between my and Calculator which shouldn't be there. To fix it, change:

Calculator my Calculator = new Calculator();

to

Calculator myCalculator = new Calculator();
11/20/09

188Error in Text
Top of the page:

The default is Private which hides the class by default.

should be:

The default is internal (Friend in VB.NET) which makes the class visible to other classes in the same assembly (a.DLL) but hides it from code outside the assembly)
06/12/2008

6197Error in Code
To match figure 6-2, the code for step 3, line 3:

<div id="Header"><a class="HeaderLink" href="~/" runat="server"></a></div>

should be:

<div id="Header"><a class="HeaderLink" href="~/" runat="server">Header Goes Here</a></div>
04/10/2008

6202Typo
first paragraph under Nested Master Pages, last sentence says:
for nested maser pages

should be:
for nested master pages
09/23/08

6202Error in Text
Last sentence of the second paragraph says that the content control will be empty, but that's not the case. Replace the text:

This will add an empty <asp:Content> control to the page that you can fill with your own content.

with the text:

This will copy the default contents into a new control which you can then modify.
5/27/09

206, 207Error in Code
Chapter 6: Page 206 / 207 Note

The code on these pages checks the page's title for the text "Untitled Page" to make sure a page with this meaningless title never makes it to a production site. However, Service Pack 1 for Visual Web Developer 2008 (which was released after this book was published) has changed the default behavior. Pages now no longer have "Untitled Page" as their title, but an empty string instead. If you want the BasePage to check for empty strings as well, change the code on page 206 and 207 to this:

206 (VB)

If Me.Title = "Untitled Page" Or String.IsNullOrEmpty(Me.Title) Then
Throw New Exception("Page title cannot be "Untitled Page" or an empty string.") End If



207 (C#)

if (this.Title == "Untitled Page" || string.IsNullOrEmpty(this.Title)) {
throw new Exception("Page title cannot be \"Untitled Page\" or an empty string."); }



Notice the extra check for the empty title using the IsNullOrEmpty method on the String class.
2/6/09

6212Error in Text
Step 7 contains the text: "Type MyBasePage as the new page name." Instead of "new page name," this should have been "template name."
9/14/09

6231Error in Text
In the last paragraph

"Default.aspx"

Should be

"SkinDemo.aspx"
4/20/09

7239Error in Text
1st paragraph:

"been modified to refer to an image in the same document as"

should be

"been modified to refer to an image in the same folder as"
1/12/09

241Error in Text
third sentence from the end:

"The Menu on the right displays Home only when the page first loads."
(This implies that Home is only displayed when the page first loads, but not later.)

should be:

"When the page first loads, the Menu on the right only displays Home."
06/13/2008

7242Error in Code
<siteMapNode url="~/ " title="Home" description="Go to the homepage" />

should be:

<siteMapNode url="~/ " title="Home" description="Go to the homepage">
1/12/09

7244Error in Text
Internet Explorer 8 and ASP.NET 3.5 don't play nice together when it comes to rendering the Menu control. When you view the menu in that browser, the sub menus are all blank and the menu text doesn't show up. The problem is caused by a change in the rendering engine of IE 8 to more strictly stick to the W3C web standards. You can fix the problem in two ways:

1. Add a high z-index to the .DynamicMenuStyle class (that you may need to add to your CSS file) first like this:

.DynamicMenuStyle
{
z-index: 1000;
}

2. Install a patch released by Microsoft.
http://weblogs.asp.net/bleroy/archive/2009/03/23/asp-menu-fix-for-ie8-problem-available.aspx

For more information, see these posts and articles:

http://p2p.wrox.com/book-beginning-asp-net-3-5-c-vb-book-isbn-978-0-470-18759-3/73512-ie8-menu.html

http://blogs.msdn.com/giorgio/archive/2009/02/01/asp-net-menu-and-ie8-rendering-white-issue.aspx
7/10/09

7247Error in Text
The first paragraph on the page talks about the <page> element in web.config, but this should be the <pages> element.
9/14/09

7254Error in Text
The line above Step #1 of Try It Out:

...write some code that either shows the Menu or the TreeView...

To be grammatically correct, it should read:

...write some code that shows either the Menu or the TreeView...
4/27/09

258Typo
Second to last sentence of the last paragraph:
directly go the content

should be:
directly go to the content
09/10/08

8271Error in Step
first line of step #10:

...Wrap the Image in a standard element and set its src attribute...

should be:

...Wrap the Image in a standard
element and set its href attribute...
08/25/08

8275Error in Text
Chapter 8, page 275, section "How It Works," second paragraph, first sentence, first clause:

When you add the control registration to the master page

Should be:

When you add the control registration to the web.config file
06/24/2008

276Error in Code
The code says to add code to the Page_Load event. However, that should be Page_Init to avoid problems in more advanced scenarios. So this code:

VB.NET
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) _
Handles Me.Load
Me.ID = "Master"

C#
protected void Page_Load(object sender, EventArgs e) {
this.ID = "Master";


should be:

VB.NET
Protected Sub Page_Init(ByVal sender As Object, ByVal e As
System.EventArgs) _
Handles Me.Init
Me.ID = "Master"

C#
protected void Page_Init(object sender, EventArgs e) {
this.ID = "Master";


For more info, please the following Blog post on the author's web site:
http://imar.spaanjaars.com/QuickDocId.aspx?quickdoc=469
09/11/08

299Error in Text
Chapter 9, page 299, section "Extending the Contact Form," item #2, first sentence:

Save button

Should be:

Send button
06/26/2008

311Error in Text
This allows you, for example, to create a MailAddress instance like this:

should be:

This allows you, for example, to create a MailMessage instance like this:
06/12/2008

10325Error in Text
How It Works section, second paragraph. The sentence:

The ScriptManager you placed in the master page....

Should read:

The ScriptManager you placed in "UpdatePanel.aspx"....
4/20/09

357Error in Text
You should use the App_Data folder only for data that is used at server

should be

You should use the App_Data folder only for data that is used at the server
11/02/08

11364Error in Text
The second paragraph under the How It Works heading is referring to an incorrect step number. The text:

The query shown in step 9

Should be

The query shown in step 8
9/14/09

372Error in Table
Page 372, the table with data types contains a row for the varchar/nvarchar datatype. The Description column for that row should be changed from:

=======================================
Used to store text with a variable length.
The nchar stores the data in Unicode format, which allows you to store data for many foreign languages.
=======================================

to

=======================================
Used to store text with a variable length.
The nvarchar stores the data in Unicode format, which allows you to store data for many foreign languages.
=======================================
07/09/2008

12400Error in Code
Top of page, in the highlighted box that shows, "Your final code should look like this:", the second to last line in the box:

ORDER BY [Name]

should be

ORDER BY [SortOrder]
12/16/08

12410Error in Code
Due to a change in Service Pack 1 of VWD (to support SQL Server 2008) some issues my arise in the Try It Out on page 410 (and other TIO's that use an SqlDataSource and a DateTime column). VWD incorrectly infers a Date data type instead of a DateTime. After step 6 on page 411 you may end up with the following code in the SqlDataSource:

<asp:Parameter DbType="Date" Name="UpdateDateTime" />

However, the correct DbType should be a DateTime instead of a Date:

<asp:Parameter DbType="DateTime" Name="UpdateDateTime" />

Without this change, you may receive the following error when you request the page:

"The version of SQL Server in use does not support datatype 'date'"
4/9/09

420Error in Text
In the How It works section:

<asp:RequiredFieldValidator ID="RequiredFieldValidator2"
runat="server" ErrorMessage="Please enter a title."

But that should be:

<asp:RequiredFieldValidator ID="ReqVal2" runat="server"
ErrorMessage="Please enter a title."
11/6/09

12423Error in Text
Question 1 on page 423 asks you what control you should use to hook up the data control to the database. The explanation in Appendix A doesn't mention the SqlDataSource control that is needed (as you haven't seen LINQ at this stage) to hook up the control to the database.
4/20/09

430-remainderError in Code
Error on 430 and through the remainder of the book: On non English versions of Visual Web Developer (VWD) or Visual Studio (VS) 2008 you may get unexpected results when working with the LINQ to SQL classes designer. The problem lies in the way the designer pluralizes tables names in the designer. For example, when you drag a table called Review on the designer, VWD / VS will automatically expose a Reviews property on the data context so you can access it like this:

VB.NET
Using myDataContext As New PlanetWroxDataContext() Dim allReviews = From review In myDataContext.Reviews _ Where review.Authorized = True _ Order By review.CreateDateTime Descending _ Select review End Using

C#
using (PlanetWroxDataContext myDataContext = new PlanetWroxDataContext()) { var allReviews = from review in myDataContext.Reviews where review.Authorized == true orderby review.CreateDateTime descending select review; }

Notice how the myDataContext property has a Reviews collection (plural) even though the original table was called Review in singular form. This only works on English versions of VWD / VS.

On other languages, the table won't be pluralized automatically. In that case, the PlanetWroxDataContext has a Review property. This means you'll need to adjust code examples as the one on page 430 to use the Review collection:

VB.NET
Using myDataContext As New PlanetWroxDataContext() Dim allReviews = From review In myDataContext.Review _ Where review.Authorized = True _ Order By review.CreateDateTime Descending _ Select review End Using

C#
using (PlanetWroxDataContext myDataContext = new PlanetWroxDataContext()) { var allReviews = from review in myDataContext.Review where review.Authorized == true orderby review.CreateDateTime descending select review; }

The same problem may be present in other LINQ to SQL code examples in the book.

Instead of adjusting the code, you could also rename the Review property in the code. You'll find the property in the PlanetWrox.designer.cs class:

public System.Data.Linq.Table Review { get { return this.GetTable(); } }
09/11/08

431Error in Text
third paragraph, fourth line, fourth word:

"off"

should be:

"of"
06/27/2008

13459Error in Code
Code example at the top of the page: The definition for the Label button is followed by an empty element that shouldn't be there:

<asp:Label ID="TooltipLabel" runat="server" Text='<%# Eval("Tooltip") %>'
/>< />

Should be:

<asp:Label ID="TooltipLabel" runat="server" Text='<%# Eval

("Tooltip") %>' />

In addition, the definition for the Delete button has an extra double-quote.

<asp:Button ID="DeleteButton" runat="server" CommandName="Delete" " />

should be

<asp:Button ID="DeleteButton" runat="server" CommandName="Delete" />
9/14/09

13464Error in Text
Second paragraph of the How it Works section, 5 lines up from the bottom of the paragraph, the word "false" should be "true."

It says, "...you can set the Cancel property of the e argument that is passed to the event handler to False..." The "False" should be "True" because in the Try It Out section, the cancel property is set to "True."
1/12/09

14489Error in Text
First sentence of the last paragraph:

and asks for that control for its data.

should be:

and asks that control for its data.
9/14/09

14491Error in Text
In step 3 you get an instruction to add an Imports statement to the Code Behind if you are using Visual Basic. Changes to the latest Service Pack for Visual Web Developer (which was released after this book was published) now require a "using" statement as well if you are using C#. Step 3 on page 491 should therefore read:

3. At the top of the Code Behind of the document add the following line of code:

VB.NET
Imports System.Data

C#
using System.Data;

Adding "using System.Data;" brings this namespace in scope for the C# project as well so you get access to the DataRowView class.
4/27/09

14493Error in Text
On Top of Page:
GridView1_RowRowDataBound

should be:
GridView1_RowDataBound
09/29/08

14509Error in Code
Top of page, within the VB code, the last line of the VB code that says "this.Title,"

should be

"Me.Title."
1/12/09

15528Error in Text
last two sentences:

"... then press Ctrl+V to paste your LoginView,"

should be:

"... then press Ctrl+V to paste the Login control into your LoginView."
06/26/2008

529Error in Text
section 5, second sentence:

"The LoginView should be placed inside the AnonymousTemplate..."

should be:

"The Login control should be placed inside the AnonymousTemplate..."
06/26/2008

550Error in Text
second paragraph, second and third sentences:

"The run time then found the allow element that grants access to the Managers role and immediately lets you in. The final rule that blocks access to all other users is never even checked anymore."

should be:

"The runtime then found the allow element that grants access to the Managers role and immediately let you in. The final rule that blocks access to all other users was not even checked."
06/24/2008

15552Error in Text
In Service Pack 1 for Visual Web Developer (which was released after this book was published) the default templates for new Web Forms have changed and now contain fewer "using" statements for the C# web forms. This means you manually need to add some "using" statements to make some examples work.

In order for the Roles class to be available in the C# example in step 5 on page 552, you need to add a "using" statement for the System.Web.Security namespace. To do this, add the following to the top of the Code Behind file, before the class definition:

using System.Web.Security;

VB.NET imports this namespace by default so you don't need to add it when you're using that language.
7/10/09

558Error in Text
"run time"

should be:

"runtime"
06/24/2008

16559Error in Table
The third row, second cell of the table refers to anonymousAuthentication which should be anonymousIdentification
9/14/09

561Error in Text
"Chapter 5 discusses how to use generics to store role names using a generics list of strings."

should be:

"Chapter 5 discusses how to use generics to store role names using a generic list of strings."
06/24/2008

17604Error in Code
step 9: The code reads:
<h1>Un unknown error occurred</h1>

But should read:
<h1>An unknown error occurred</h1>
4/7/11

18635, 636Error in Text
In Service Pack 1 for Visual Web Developer (which was released after this book was published) the default templates for new Web Forms have changed and now contain fewer "using" statements for the C# web forms. This means you manually need to add some "using" statements to make some examples work.

In order for the ConfigurationManager class to be available in the C# example on page 635 / 636, you need to add a "using" statement for the System.Configuration namespace. To do this, add the following to the top of the AppConfiguration.cs file, before the class definition:

using System.Configuration;

VB.NET imports this namespace by default so you don't need to add it when you're using that language.
7/10/09

App A674Error in Code
There's no reason for </p> at the end of the User Control code. So this

<uc1:ContactForm ID="ContactForm1" runat="server"

PageDescription= "Contact Page" /></p>

Should be:

<uc1:ContactForm ID="ContactForm1" runat="server"

PageDescription= "Contact Page" />
9/14/09

678Error in Excercise 3 Solution Code
Exercise 3 solution code is incorrect.

<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# "PictureDetails.aspx?Id=" + Eval("Id") %>'>

Should be:
<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# "PictureDetails.aspx?Id=" + Eval("Id").ToString() %>'>
09/08/08