Preparing for the Sample Application
The sample application is built using Microsoft SQL Server's Northwind
sample database. If you do not have Microsoft SQL Server available, you can
use the Access/Jet version of the same database, Northwind.mdb file
supplied with the sample files for this book.
TIP
If you're going to use the Northwind database, you'll need to change the
connection string in DataHandler.vb to point to the Northwind.mdb file
supplied with the examples. You can find the connection string in the
DataHandler.vb file in the completed Northwind sample project. You will be
unable to run the examples that involve stored procedures, because
Microsoft Access (and the Jet database engine) doesn't support stored
procedures.
Installing the Examples
We have supplied a Microsoft Installer 2.0 (MSI) file that will create all
the sample applications for this book on your machine. Before you can
install the examples, the following items must be installed on your
computer:
Operating system. You must be running Windows NT Workstation or Server,
Windows 2000 Professional or Server, Windows XP Professional, or Windows
.NET Server. If you have any other OS, you may not be able to run Visual
Studio .NET. Check with Microsoft to see if your operating system will run
Visual Studio .NET. Some operating systems (such as Windows NT) require
additional service packs in order for Visual Studio to run.
Visual Studio .NET. Every example in this book requires you to have Visual
Studio .NET 2002 installed on your computer.
Internet Information Server. IIS is an optional component in non-server
operating systems (such as Windows XP Professional, Windows 2000
Professional, and so on). Use the Control Panel's Add or Remove Programs
option to install IIS.
SQL Server. Although this database system is highly recommended, you can
also use the supplied Access MDB file.
If you have all the installation criteria, you should be able to run all
the examples for this book. To install the sample files, follow these steps:
Go to http://www.pdsa.com/ASPNETJumpstart. You can download the sample
files (and any updates) from this Web site.
Download ASPNETJumpstart.MSI to a location on your local hard drive.
Execute the MSI file by double-clicking it in Windows Explorer.
Follow the prompts presented by Windows Installer, as it installs the
examples.
Once you're done installing the examples, you'll find a new folder tree,
starting with <d>:\ASP.NET Jumpstart. Under this folder, you will find
other folders that are described in the next section.
Before You Get Started
Before you get going, it's important to review some issues that will affect
you as you follow the examples and create your own Web pages throughout the
book. We'd like to take this opportunity to mention some important general
instructions that apply to all the following chapters. Not all these issues
will seem relevant as you're getting ready to start working through the
chapters, but you may want to refer back to this section later on梞ake sure
you at least skim through this list before proceeding so you know what's
covered here:
Folder structure. We've supplied three directory "trees": Jumpstart,
Jumpstart-Completed, and Jumpstart-SampleCode. The Jumpstart folder
contains completed projects, ready for you to run (for example, the
Debugger, ErrorHandling, FrameworkClasses, and VBLanguage folders). These
projects exist outside the main Northwind example and show off particular
features that didn't fit into the main project. This folder also includes
the Northwind-Completed subfolder, which contains the finished sample
project you'll create as you work through this book. You'll also create
your Northwind sample project in this folder, as well as other projects
throughout the book. The Jumpstart-Completed folder contains a series of
subfolders, one corresponding to each chapter in the book in which you
modify the Northwind sample project. Each subfolder contains a full copy of
the Northwind sample project, up to the point of completion at the end of
the corresponding chapter. See the "Typing code" bulleted point for more
information about the third directory tree.
Building the sample project. Our intent, when writing this book, was that
you would work through the chapters in order, building the sample
application as you go. (Some chapters load other projects or have you
create projects not directly related to the Northwind sample project, but
the majority of the chapters focus on creating this one example.) When you
start building the example, you'll create a virtual root named Northwind,
and you'll add pages to this root as you work through the book. In some
chapters, you will build the sample pages yourself; in others, you will
bring in a completed page or a partially completed page and finish it by
following the steps in the book.
Using the finished versions of projects. If you want to skip ahead to a
particular chapter, you can find the appropriate subfolder for the chapter
right before the one you're skipping to in the Jumpstart-Completed tree.
Copy the contents of the folder to your Northwind folder (the location
where you placed the Northwind virtual root) and continue from that point,
as if you had worked through all the chapters up to that point. At any
time, you can wipe out the contents of the Northwind folder (if you're
going to do this, make sure and delete all the files and folders, as well);
then add in the contents of any of the subfolders in the
Jumpstart-Completed tree. Table 1.1 lists the chapters for which we've
supplied finished versions of the Northwind sample project. (The
Jumpstart-Completed/Northwind folder contains all the sample pages,
including all the code.) If you work through the book in order, you won't
need to worry with any of these details.
TIP
If, for example, you had completed up to Chapter 8, (ValidationControls)
and you now wanted to skip ahead to Chapter 15 (StoredProcedures), you
would need to find the most recent previous chapter that provides a full
copy of the sample project (in this case, Chapter 14: WorkingWithData) and
copy the contents from the Jumpstart-Completed/ WorkingWithData folder into
your working project's folder. You could then continue with Chapter 15 as
if you had worked through all the chapters up to that point.
Loading the projects. To load the sample projects, look for *.sln in the
folder associated with each of the chapters. A Visual Studio .NET solution
can contain multiple projects, and the SLN file contains information about
each of the individual project files (*.vbproj) included in the solution.
You can double-click an SLN file to load the solution into Visual Studio
.NET. If, for some reason, you can't find an SLN file, you can also
double-click the project's VBPROJ file to load the single project into
Visual Studio .NET.
Handling virtual roots. Each SLN file contains information about the
virtual roots where it can find each of the VBPROJ files it needs to load.
Normally, if you use the Microsoft Installer (MSI) file we've supplied to
install the examples, the virtual roots you need will already be created
for you. If there's a problem finding a virtual root, Visual Studio .NET
won't be able to load your project. You can always open the SLN file for
your solution within a text editor (such as Notepad) and view or edit the
virtual root the solution requires.
TIP
The virtual root information is also embedded in the *.vbproj.webinfo file
associated with a project. The information in this file is transient and
will be re-created for you when you restart Visual Studio .NET. If you find
that you're having trouble loading a project, and you need to re-create or
modify virtual roots, you can always delete this file so that you only need
to worry about the one file that contains path information: the *.sln file.
Adding existing pages. Some chapters require you to add existing pages to
your sample project. In each case, instructions in the chapter will direct
you to a particular folder within the Jumpstart directory tree. You'll be
asked to copy files from the specific folder (using Windows Explorer) and
then to paste the files into your project, within Visual Studio .NET. When
you do this, Visual Studio .NET will place a copy of each file into the
folder containing your project梱ou needn't worry about modifications you
make affecting the originals, which remain intact.
Using existing projects. When you load an existing project and then press
F5 to begin running the project, Visual Studio .NET must know what the
start page is for your project. If you receive an error message from Visual
Studio .NET as you begin running your project, you can right-click the
start page in the Solution Explorer window and then select Set as Start
Page from the context menu. For most chapters, the start page will be
Main.aspx. Some of the chapters may use a different start page, but those
instances are called out appropriately in the text.
Typing code. Some chapters contain a significant amount of code. You may
want to type all the code yourself (it's all printed in the book梩here's no
"hidden" code), but you may want to copy and paste it into your project,
instead. Although we find that we learn a great deal by actually typing the
code, we've provided all the code in files named Code.txt, within the
folder Jumpstart-SampleCode. You can locate the file named Code.txt in the
subfolder listed in the SampleCode column of Table 1.1. Load the file into
any text editor and then copy/paste the appropriate chunk of text into your
project.
Flow layout versus grid layout. Although Visual Studio .NET supports two
ways to lay out pages (you control which you want by setting the page's
pageLayout property), we suggest that, for the most part, you use the
flowLayout setting. Selecting the gridLayout setting makes page designing
experience "feel" more like designing in Visual Basic 6, but the rigidity
of the exact placement of controls doesn't work quite as well in a Web
page. You're welcome to choose whichever layout you like, but for the
examples we've created, we always set the pageLayout property to flowLayout.
Adding controls using flow layout. When working in flow layout, you may
find it tricky to insert controls "in front of" other controls梩hat is, to
insert a control earlier on the page than an existing control. The trick is
to click the existing control and then press the left-arrow key to move the
insertion point to the left of the control. Double-click the control you'd
like to add, and Visual Studio .NET will place it immediately before the
existing control.
Setting up debugging. You'll want to be able to debug your ASP.NET
applications, and Visual Studio .NET makes this easy. If you installed VS
.NET under any other user ID than the one you use to log in to your
computer, you will need to make sure your user ID is a member of the
Debugger users group. This won't be a problem if you run under the same ID
you used when installing. Also, if you have a problem debugging, make sure
you've edited the project properties. Also, on the Configuration
Properties, Debugging page, ensure that the ASP.NET Debugging option is
selected.
Table 1.1. Find Sample Code and Finished Projects Using the Folders Listed
in This Table Chapter Finished Project Folders Under \Jumpstart-Completed
Code.txt Files in Folders Under \Jumpstart-SampleCode
Chapter 1: Getting Started with the Sample Application
Chapter 2: Introduction to Microsoft .NET
Chapter 3: Introduction to Visual Studio .NET
Chapter 4: Overview of .NET Framework Classes
Chapter 5: Introduction to Internet Programming InternetBasics
Chapter 6: Introduction to ASP.NET ASPIntro ASPIntro
Chapter 7: Working with ASP.NET and VB .NET VBLanguage VBLanguage
Chapter 8: Validation Controls ValidationControls ValidationControls
Chapter 9: Debugging in Visual Studio .NET
Chapter 10: Introduction to ADO.NET
Chapter 11: Data Binding on Web Forms DataBinding DataBinding
Chapter 12: Error Handling
Chapter 13: ADO.NET Connection and Command Objects ConnectionCommands
ConnectionCommands
Chapter 14: Working with Data WorkingWithData WorkingWithData
Chapter 15: Using Stored Procedures with ADO.NET StoredProcs
Chapter 16: Using the DataGrid Control DataGrid DataGrid
Chapter 17: Editing Data Using the DataGrid Control DataGridEditing
DataGridEditing
Chapter 18: Using the Repeater Control Repeater Repeater
Chapter 19: Using the DataList Control DataList DataList
Chapter 20: Using Crystal Reports CrystalReports CrystalReports
Chapter 21: Creating User Controls CreatingControls CreatingControls
Chapter 22: Rich ASP.NET Controls
Chapter 23: State Management in ASP.NET
Chapter 24: Introduction to Web Security Security Security
Chapter 25: Creating Mobile Web Applications Mobile
Chapter 26: Development and Deployment Techniques
Chapter 27: Introduction to XML XMLIntro XMLIntro
Chapter 28: Introduction to XML Web Services
Chapter 29: Creating and Consuming XML Web Services WebService
Chapter 30: Investigating Web Service Consumers WebServiceAsync
Chapter 31: Securing Web Services WebServiceSecurity
SETTING UP FOLDERS CORRECTLY
When you are working on Web projects on your local machine, it is NOT a
good idea to create all your folders underneath the \inetpub\wwwroot
folder. This folder can become cluttered over time. In addition, in most
medium-to-large Web applications you create, you will most likely not
create the whole application under just one virtual root. We suggest that
you create your own virtual root, somewhere outside of the \inetpub\wwwroot
folder, and store your application in this new location.
If you've created a new virtual root named MyASPApps, for example, you can
browse to this root as http://localhost/MyASPApps. From within Visual
Studio .NET, you can create new projects under that same root by specifying
the root when prompted for a project location.
To have Visual Studio .NET select your folder as its default project
location, follow these steps:
Load Visual Studio .NET.
Select the Tools, Options menu item.
Select Environment, Projects and Solutions.
Change the Visual Studio Projects Location setting to the same folder where
you created the virtual root.
Select Projects, Web Settings.
Change the location of the Web project cache to a folder you can find
easily (for example, D:\MyASPApps\VSWebCache). This folder will become
cluttered, and you want to put it somewhere you Scan find it and
periodically clean it out.
TIP
Although we've covered a lot of material in this book, there's a lot more
depth and breadth of material available. We suggest you start by visiting
Microsoft's .NET site, http://www.gotdotnet.com. Also, make sure you
investigate the Quickstart examples that ship as part of the .NET
Framework. Look in the documentation for more information.