What is this book about?
With this book and Web Matrix, you'll be developing your own powerful ASP.NET websites in no time.
You'll start at the beginning, learning how to create graphical web pages in Web Matrix. Then you'll use Visual Basic .NET and databases to add the dynamic features usually seen in expensive commercial websites. You'll finish by looking at some of the expert ASP.NET features — writing our own controls and web services.
Even if you've never programmed before, this book will take you right into the world of professional web development. You'll be amazed at how easy it is and how much you can do.
What does this book cover?
With this book, you will learn how to
- Go further than just static HTML websites, by using a programming language. We will get you building real dynamic websites right from the beginning
- Change the content of your pages quickly and easily by using databases. With this book, you'll learn how databases work, and how to make the most of them.
- Add interactivity to your website by creating your very own guest book, and allow people to leave message with emoticons.
- Create content you can distribute to other websites, and learn how to automatically update it all over the Web in one go!
Who is this book for?
Users of any edition of Microsoft Windows XP, or 2000 — ideal for beginners — no HTML knowledge is required.
Microsoft has informed us that the version of MSDE distributed with this book is susceptible to the slammer worm. Microsoft is providing a patch for this version of MSDE at the following URL: http://www.msdn.microsoft.com/netframework/downloads/updates/sdkfix/default.asp.
If you have installed MSDE using the CD in the book, and wish to protect yourself from this virus, you should consider applying this patch. We are very sorry for any inconvenience caused.
About the Author
David Sussman has spent the majority of his professional life as a developer, using both Unix-based and Microsoft-based products. After writing his first two books while in full time employment, he realized that being an author sounded more glamorous than being a programmer. The reality is somewhat different. He now spends most of his time writing books for Wrox Press, speaking at conferences, and playing with most beta products that Microsoft ships.
James Greenwood is a technical architect and author based in West Yorkshire, England. He spends his days (and most of his nights) designing and implementing .NET solutions from Government knowledge-management systems to mobile integration platforms, all the while waxing lyrical on the latest Microsoft technologies. His professional interests include research into distributed interfaces, the automation of application development, and human-machine convergence.
When he can be prised away from the keyboard, James can be found out and about, indulging in his other great loves – British sports cars and Egyptology.
You can reach James at email@example.com.
Alex Homer is a software developer and technical author living and working in the idyllic rural surroundings of the Derbyshire Dales in England. He came to computing late in life - in fact, while he was at school people still thought that the LED wristwatch was a really cool idea. Since then, he has obtained a Bachelor of Arts degree in Mathematics, and so, looked destined for a career painting computers. Instead, while not busy developing ASP components for Stonebroom Software (http://www.stonebroom.com), he prefers to install and play with the latest and flakiest beta code he can find - and then write about it. You can contact him at firstname.lastname@example.org or email@example.com.
Colt Kwong is a Microsoft .NET MVP, software developer, technical writer, and addict of all things about .NET. He's one of the top posters and a moderator on the Microsoft official ASP.NET forums at http://www.asp.net/Forums/. He also contributes on other popular websites and newsgroups as well. He spends a great deal of his free time providing help to budding ASP.NET developers. He is a guest speaker for Microsoft Hong Kong TechEd and a freelancer for Microsoft Hong Kong. He's in the Winner's Circle for Microsoft's Asia Student .NET Online Challenge, earning perfect scores in advanced, intermediate, and basic levels of .NET, ASP.NET, XML web services, XML, Visual Basic .NET, Visual Studio .NET, and HailStorm. Moreover, he was also recognized as one of the Level 2 AspElite members and is a Moderator of AspFriends.com .
John West is a Principal Consultant at Intellinet (www.intellinet.com), based out of Atlanta, Georgia. He specializes in leading Microsoft .NET application development efforts. Intellinet provides infrastructure and business intelligence solutions. Intellinet's Intelligent Enterprise integration solution helps clients to benefit from systems that meet current needs and can scale to future demands. Often, .NET applications become the glue to integrate the Intelligent Enterprise, which consists of networking, security, messaging, collaboration, custom applications, data, and mobility solutions.
When not working, he usually spends his time reading, hanging out with friends from church, and boating. John can be reached at firstname.lastname@example.org.
Read an Excerpt
Beginning Dynamic Websites: with ASP.NET Web Matrix
By Dave Sussman James Greenwod Alex Homer Colt Kwong John West
John Wiley & Sons
Copyright © 2003
Dave Sussman, James Greenwod, Alex Homer, Colt Kwong, John West
All right reserved.
Installing and Exploring
So, you want to be a web developer eh? You want to write great looking Internet applications,
but don't want to learn lots of arcane programming stuff? I can't say I blame you - most
programming these days is far more complex than it needs to be. However, this doesn't have to
be the case, so don't think it's beyond you - we're going to show you something that'll get you
creating great applications in no time at all.
When Microsoft released ASP.NET in early 2002, Web development got much easier. The
trouble was that it was still too hard for many people. Why? The breadth of what ASP.NET was
able to do left some people floundering. Many developers who were used to an older way of
creating dynamic web applications were overwhelmed by the scale of ASP.NET. But the
problem wasn't with the new features; it was more a case of understanding how to make these
new features work, both conceptually, and in practice. The development tool that Microsoft
supply is designed forlarge-scale web application development, and such it is quite complex.
It's also expensive - and both of these factors put many people off.
The solution to this particular problem is an easy-to-use tool, at the right price. That's where the
Microsoft ASP.NET Web Matrix Project comes in. In this book we're going to teach you how to
create great web applications using the easiest, and cheapest of tools. In this chapter we're
going to look at:
How and why Web Matrix came to life
How to install the Microsoft .NET Framework, and associated products
How to install the Microsoft Web Matrix development tool
How to use the features available in Web Matrix
As we go through the book you'll see how easy web development can be when using the right tool.
What is the Microsoft Web Matrix?
Microsoft Web Matrix is a web development tool designed for creating ASP.NET web pages. A
simple description, but it doesn't really tell you much, such as what it does, why you should
use it, and why it's available in the first place. You might not think those are important
questions, but the answers give you some ideas as to why you'd want to use Web Matrix.
When .NET was released, the main development tool promoted was Visual Studio .NET (VS .NET).
As Web developers, we've been used to a plethora of tools, but more often than not, when coding
old-style ASP pages, we've used Notepad. It's small and quick, but doesn't have any features
specifically designed for web development. VS .NET brought a really rich design-time environment,
including database support, drag-and-drop design, and so on. However, VS .NET is an advanced
development tool, with many features not required by many people creating ASP.NET applications.
The Web Matrix Project on the other hand, was designed with ASP.NET in mind. It's very small
(it fits on a floppy disk), has great design features, and best of all, it's free!
Web Matrix Features
Before we dive into the installation, let's take a quick look at the features of Web Matrix, to see
why it's so compelling:
It's small. This means it's quick to download, copy, or distribute to friends. It also
means it doesn't take much memory or disk space.
It has got great design features, such as a drag-and-drop page designer, templates for
existing web pages, pre-supplied code, and so on. This makes it extremely easy to use.
It doesn't require any other files. VS .NET uses a project-based system that creates
extra files to manage a project. Web Matrix just uses a single file for each web page,
and doesn't rely on any built-in features. This means that you can edit the pages in any
other code editor if you need to.
Community support. There's built-in support for links to the ASP.NET community,
including the news groups and mailing lists.
Oh, and did I mention it's free? You can (and are encouraged to) freely distribute Web Matrix.
Let's now run through the installation so you get to play with Web Matrix as quickly as possible.
Installation of Web Matrix is simple, and takes place in several steps. Inserting the Web Matrix
CD (included in the back of this book) will bring up a web page outlining the installation steps.
If the web page doesn't appear, then just run the startcd.exe program from the CD
directly - this will launch the start page.
Installing Microsoft .NET
Before you can install Web Matrix you need to install the .NET Framework. If you've already got
this installed then you can skip this step. The version on the Web Matrix CD is .NET Framework
1.0. From the main start page from the CD you'll see a set of steps, labeled 1 to 4. If you follow
these in order you end up doing more work than is necessary, so skip straight to Step 4.
The .NET Framework SDK, installed in Step 4, includes the .NET Framework, the MSDE
database setup utility, the ASP.NET quickstart code samples, and the .NET Framework
documentation. The only thing it doesn't include is Web Matrix, which we'll install
from Step 2.
1. Pick the right hand link, to install the Microsoft .NET Framework Software
Development Kit (SDK). This installs .NET version 1.0, plus all of the documentation:
2. Click Open to start the installation. You may receive this warning:
This just tells you that you haven't got a web server installed on the machine. Don't worry
about this, as Web Matrix comes with its own web server, so you don't have to install a web
If you have IIS installed on your system, you can use either the IIS web server, or the web
matrix web server once you've installed Web Matrix - the Web Matrix installation
doesn't overwrite anything, and the two co-exist nicely.
So if you do see this message, just press Continue and you should see the following:
3. Press Next to start the installation wizard:
4. Select I accept the agreement, and press Next to continue:
5. Make sure that both optional checkboxes are ticked, and press Next:
6. Leave the settings at their defaults, and press Next. This starts the SDK installation,
and it's time to go and make a cup of coffee - watching the install screen is rather dull.
Once this stage of the installation is finished, you can, and should, take time to install the
service packs (which are updates designed to fix small bugs and potential security holes in the
Framework). You can either install just the first service pack from the CD (as linked in Step 1),
or you can go to the Microsoft Windows Update site (windowsupdate.com) and
download the most recent service packs.
Installing the Database Server Software
Once the SDK installation has finished, you need to install the database server software - this
will allow you to run the sample applications, as well as create your own databases.
1. Select the Microsoft .NET Framework SDK program group, and then select Samples
and QuickStart Tutorials.
2. From the resulting page, select Step 1: Install the .NET Framework Samples Database:
3. You'll then be prompted with the following - select Open. This will install the
4. After rebooting your system, if you have IIS installed on your system, you can
continue to Step 2 of the quickstart installation, and install the samples and tutorials.
Included in this installation are four sample databases, one of which we'll be using
later on, so we recommend that you then run Step 2 in the installation.
Installing the Sample Databases Manually
If you don't have IIS installed on your system, you can install it (on compatible operating
systems) by following the instructions in Appendix A, then follow Step 2. For those of you who
don't have the option of installing IIS (if you're running Windows XP Home Edition, or if you
simply don't want to install IIS), you need to run some different code to install the database
we'll use later in the book. You need to run a small installation script, available with the
Chapter01 code download for this book (the details of how to download the code for this
book are in the Introduction).
To install the databases using the installation script file in the code download for this chapter,
open the Chapter01 folder, within the BegWebMatrix downloaded folder. Run the
InstallDatabases.bat file, and the installation script will run and install the databases.
When it's finished running, you will see the following screen:
After this installation, you will have a database configured to run with the instance name
of (local)\NetSDK, and you will have access to four sample databases on that server.
You'll find out more about what this actually means in Chapter 8.
Installing Web Matrix
At this stage you now have both .NET and database software installed. All that's left is Web
Matrix. Now you can switch back to the screen from the CD (if it's closed just run
startcd.exe from the root directory of the CD), and scroll to Section 2:
1. To install Web Matrix click the first link, to give the following:
2. Click Open to start the installation:
3. Click Next to continue:
4. Enter your User Name and Organization (you can leave this blank if you like). By
default the Web Matrix will be available for all users who use the computer, but you
can make it available only to yourself. I'd recommend leaving the default here. Press
Next to get to the features screen:
5. Since Web Matrix is very small and has all of its features included, there's not much to
choose here. Just leave the settings as they are and press Next to perform the installation.
6. Once complete you can check to see if the installation was successful by running Web
Matrix - there will be a new menu under the Programs menu from the Start button - it
will be labeled Microsoft ASP.NET Web Matrix:
Upon starting Web Matrix you'll see the following screen:
We'll look at these options a little later, but now you know it works, let's carry on looking at the
Tours and Tutorials
As part of the set up routine from the Web Matrix CD there are three extra features. The first is
a video, with some interviews with users of Web Matrix, telling you how great it is.
The Web Matrix Guided Tour
The second is the guided tour - a set of HTML pages explaining how some of the features can
ASP.NET Quickstart Tutorial
The third is the tutorial for ASP.NET itself.
You don't need to explore any of these in detail yet, so let's carry on with the installation.
However, once you've started using ASP.NET it's worth spending some time browsing through
the ASP.NET QuickStart Tutorial. It's full of great examples of ASP.NET.
Visit the Web Site
The home of ASP.NET is shown in the last step of the installation screen:
This site is maintained by the Microsoft team that develops ASP.NET, and should be on your
Favorites list. Not only is it where new announcements are made, where articles are posted,
and where controls are available, but it also provides a set of forums. These are invaluable for
getting help with ASP.NET problems, and it's well worth joining.
A Tour of Web Matrix
Now you've done all of the installation tasks, it's time to start looking into Web Matrix, to see
exactly what features it has, and how to use them. This will be a quick tour around the interface
so you know what each section is, and how it's used. The specifics of each area will be
investigated in later chapters, as each becomes relevant.
New Item Dialog
Let's start with the New Item dialog. This is what you see when you want to create a new
ASP.NET file, and is the first thing you see when you run Web Matrix:
At the top we have two sections for templates - one for the type of template, and one for the
template itself. Underneath that we have two text entry areas, where you can specify the
location of the file, and its name. You should make sure you leave the file suffix (.aspx in this
case) at the end of the file name, since Web Matrix doesn't automatically add one.
In the Code section at the bottom of the screen, there is a selection list to pick the language you
want to use when writing code. We're going to be using Visual Basic .NET in this book (the
other language you could use is C#). Finally there is a checkbox to allow you to specify
advanced features for the new file. This is useful if you need to change the default class name
and namespace for the file - we'll be keeping the defaults so you should leave this unchecked
unless told to change it.
Templates in Web Matrix act just like templates in other tools, such as Microsoft Word or Front
Page. They provide a default for the style and content of the page. In some cases with Web
Matrix the templates provide almost all you need to create great web pages. There are six
template types, or groups:
(General). General templates for all types of ASP.NET pages. These don't have much
in the way of content or code.
Data Pages. Data pages, containing grids and lists. These have lots of code already in
place, and provide a quick way to have pages that show tables of data from a database.
Mobile Pages. For creating pages to be used on mobile devices, such as phones. The
Mobile Internet Toolkit needs to be installed for this, which is Step 3 on the Web Matrix
install page. We won't be looking at mobile devices in this book, but for more information
have a look on the Wrox website - there are several books that cover this in detail.
Output Caching. Pages that are cached in memory, and are therefore faster.
Security. Login and logout pages, for creating secure websites.
Web Services. Pages that can be called remotely by other applications. Web services
are Internet applications that just provide functionality, and have no interface,
allowing companies to use your code. For example, Amazon has a web service that
allows you to programmatically access its database, search for files, access your wish
list, and so on.
You'll see many of these in use as we go through the book, but feel free to have a play with
To learn about the rest of the interface, let's show you the main areas of Web Matrix.
Excerpted from Beginning Dynamic Websites: with ASP.NET Web Matrix
by Dave Sussman James Greenwod Alex Homer Colt Kwong John West
Copyright © 2003 by Dave Sussman, James Greenwod, Alex Homer, Colt Kwong, John West.
Excerpted by permission.
All rights reserved. No part of this excerpt may be reproduced or reprinted without permission in writing from the publisher.
Excerpts are provided by Dial-A-Book Inc. solely for the personal use of visitors to this web site.
Table of Contents
Chapter 1. Installing and Exploring Web Matrix.
Chapter 2. Writing your First ASP.NET Web Page.
Chapter 3. Creating Web Pages.
Chapter 4. Writing Code.
Chapter 5. Storing Different Types of Data.
Chapter 6. Working with Collections of Data.
Chapter 7. Debugging and Error Handling.
Chapter 8. Working with Databases.
Chapter 9. Displaying Data.
Chapter 10. Working with Data.
Chapter 11. Linking to Pages and Files.
Chapter 12. Reusable Content.
Chapter 13: Case Study Part 1: Extending Your Web Application.
Chapter 14: Case Study Part 2: Identifying Your Users.
Chapter 15. Remembering Your Visitors.
Chapter 16. Web Services.
Chapter 17. Beyond Web Matrix.
Appendix A. Microsoft Internet Information Server.