Table of Contents
Introduction.
Chapter 1. A Fast Track Guide to ASP.NET.
Chapter 2. Understanding the .NET Framework.
Chapter 3. The .NET Languages.
Chapter 4. Writing ASP.NET Pages.
Chapter 5. Server Controls and Validation.
Chapter 6. ASP.NET Web Form Controls.
Chapter 7. List Controls and Data Binding.
Chapter 8. Introducing .NET Data Management.
Chapter 9. Working with Relational Data.
Chapter 10. Updating Relational Data Sources.
Chapter 11. XML Data Management in .NET.
Chapter 12. Web Applications and global.asax.
Chapter 13. Configuration.
Chapter 14. Securing ASP.NET Applications.
Chapter 15. Working with Collections and Lists.
Chapter 16. Working with Other Base Classes.
Chapter 17. .NET Components.
Chapter 18. Building ASP.NET Server Controls.
Chapter 19. Exposing Web Services.
Chapter 20. Using Web Services.
Chapter 21. Mobile Controls.
Chapter 22. Tracing, Error Handling, Debugging, and Performance.
Chapter 23. Migration and Interoperability.
Chapter 24. Case Study – IBuyAdventure.NET.
Appendix A. The Common System Namespaces.
Appendix B. Scott Guthrie's Top Performance Tips.
Appendix C. References and Further Information.
Index.
Read a Sample Chapter
Professional ASP.NET 1.0
By Richard Anderson Brian Francis Alex Homer Rob Howard Dave Sussman Karli Watson John Wiley & Sons
ISBN: 0-7645-4396-2
Chapter One
A Fast Track Guide to ASP.NET Microsoft's .NET technology has attracted a great deal of press since Beta 1 was first released to the world. Since then, mailing lists, newsgroups, and web sites have sprung up containing a mixture of code samples, applications, and articles of various forms. Even if you're not a programmer using existing ASP technology, it's a good bet that you've at least heard of .NET, even if you aren't quite sure what it involves. After all, there's so much information about .NET, that it's sometimes hard to filter out what you need from what's available. With new languages, new designers, and new ways of programming, you might wonder exactly what you need to write ASP.NET applications.
That's where this chapter comes in, because we are going to explain exactly what is required, and how we go about using it. The aim is to get you up and running, able to write simple ASP.NET pages as quickly as possible, and give you a solid grounding in the basics of the new framework. This will not only benefit existing ASP programmers, but also people who haven't used ASP, including Visual Basic programmers who need to write web applications. ASP.NET makes the whole job much easier whatever your skill set.
So, in particular we are going to be looking at:
Installing and testing ASP.NET
The benefits of the new technology
The basic differences between ASP and ASP.NET
The new programming model
The rich hierarchy of server controls
We start with the simple discussion of why ASP.NET has come about.
Evolution or Revolution?
As developers, we are all used to the evolutionary cycle of software product releases, where each new release adds a few features and cures a bunch of bugs. Server-side web technology has followed this pattern, with products such as dbWeb and the IDC rapidly settling into the Active Server Pages we know and love today. ASP 1.0 was released in 1996, and although it has gone through a further two releases, it hasn't really changed that much - until now. Be prepared to throw away many of those ingrained ASP programming habits, as you've an interesting ride ahead.
ASP.NET is where the revolution begins, because it is radically different from previous versions. Its first appearance into the world was at the Wrox Conference in Washington D.C. back in 1999, where impromptu applause showed how much the audience liked the product. Then in July 2000, ASP.NET received its first public release at PDC, where around 6,000 developers were bombarded with nothing but .NET. As a consequence, they spent most of the week looking like rabbits in headlights - rather dazed and confused with all they had to take in. .NET isn't particularly difficult to understand, but ASP.NET is very different from what we are used to.
That's really the whole crux of the matter. ASP.NET is just a part of the whole .NET framework, but to use ASP.NET effectively you have to understand the underlying architecture. In the next chapter we'll outline this new architecture and the benefits it brings, but for now we need to look at ASP.NET.
Getting Started with ASP.NET
The change to ASP.NET may seem daunting to some, but in the immortal words of Douglas Adams: don't panic! Even though there's been a radical change, the basics of ASP.NET are easy to grasp, especially if you've only ever programmed in Visual Basic before. Another important point to highlight is that ASP.NET sits alongside ASP - it doesn't touch existing ASP applications at all. Therefore we don't have to worry about anything that we've previously done suddenly stopping working.
Unlike Beta 2 where there were two versions of ASP.NET, the release version comes in a single version, containing all features.
ASP.NET is supported on Windows 2000 (Professional and Server versions), Windows XP, and will be included in Windows .NET Server. It is not supported for Windows NT or the Windows 9x platforms. You can install Visual Studio .NET on these platforms and remotely use ASP.NET on the supported platforms. ASP.NET can be obtained from Microsoft, at Microsoft.com/net, asp.net/ or gotdotnet.com/, and is also part of the MSDN Subscription service.
Installing .NET
Installation is extremely simple, consisting of a single executable. This installs the framework, including ASP.NET, and includes options for the samples and documentation. During installation you may be asked to update the Microsoft Windows Installer components, and if so, you should click the Yes button to update them. This update is required for the .NET SDK installation.
You may also see the following dialog:
This indicates that MDAC 2.7 is not installed on your system. You can press the Ignore button to continue with the setup process - MDAC 2.7 isn't required for .NET, although it is recommended if you use any of the data features that interoperate with ADO.
Once the Installation Wizard starts you'll have the usual license screen followed by the options screen:
This gives you the options of installing the required components, tools and samples, as well as the SDK samples. You should leave all options ticked to ensure that everything is installed. The distributable version of the .NET framework is around 18Mb, and doesn't contain samples or documentation.
As part of the samples, a named instance of the Microsoft Data Engine (MSDE) is installed containing sample databases.
Configuring the Samples
The installation routine creates a folder called Microsoft .NET Framework SDK containing an HTML page titled Samples and QuickStart Tutorials. From this page you should follow the steps outlined:
Step 1: Install the .NET Framework Samples Database. Click this link and select Run this program from its current location to run the samples database installation routine. If you receive a Security Warning dialog you can select Yes to allow the program to run. At this point the program checks for MSDE, installing it if it isn't already installed, and then installs the sample databases.
Step 2: Set up the QuickStarts. Click this link and select Run this program from its current location to configure IIS and perform other installation routines. You may also receive another Security Warning dialog when you run this program, and you can select Yes to allow the program to run.
At this point the samples are installed, and you have the option to Launch them. You can also launch the samples by navigating to the Microsoft .NET Framework SDK menu (installed under the Programs) and selecting Samples and QuickStart Tutorials.
Running the Samples
From the main QuickStart page you should select Start the ASP.NET QuickStart Tutorial, where you will be presented with the following screen:
The left-hand portion of the screen shows the samples broken into their groups, which are:
We'll see examples of these topics throughout the book.
The right-hand side of the screen will show the samples, including descriptions and sourcecode. The sourcecode for all of the samples is available in Visual Basic, C#, and JScript. The use of these languages is discussed later in the chapter.
The Sample Applications
The sample applications should give you some good ideas of what can be achieved with ASP.NET, as well as showing how it can be achieved and some best practices for writing applications.
A Personalized Portal is a sample portal application, allowing user login, content delivery, user preferences, configuration, and so on. It's an extremely good example of the use of User Controls, which are reusable ASP.NET pages.
An E-Commerce Storefront is a small electronic-commerce site, based around a simple grocery store. It shows some good uses of data binding and templating, and how a shopping basket system could be implemented.
A Class Browser Application shows how we can browse through the hierarchy of classes and objects. Not only is this useful from a learning point of view, but it also shows how the classes are queried by run-time code. This is one of the great new features of the framework, and is explained in more detail in the next chapter.
IBuySpy.com is another electronic-commerce site, showing more features than the other sample store. It contains user logins, shopping baskets, and so on.
Additional Samples
The above list of samples describes just the ones that are installed by the SDK, but there are plenty of others available, such as a .NET version of the Duwamish site. All of the code for the samples in the book is available from the Wrox Press web site (at wrox.com). Microsoft has three additional sites where information and samples can be obtained:
asp.net is the central site for downloads and links.
ibuyspy.com is the IBuySpy application online. This code runs online as well as being available as a download (in VB.NET and C#). This site also contains links to a portal based version of IBuySpy, allowing user customization, and a news based version, aimed at content delivery.
gotdotnet.com is a community site for all .NET developers. It's full of links and samples by both Microsoft and third parties. This site also has a list of ASP.NET hosting companies. There are also plenty of third party sites, and since this list may change, your best bet is to go to gotdotnet.com and follow the links page.
Visual Studio .NET
Although this book is primarily aimed at ASP.NET, it is important that we mention Visual Studio .NET as well. The first thing to make clear is that Visual Studio .NET isn't required to write ASP.NET applications, but it does provides an extremely rich design environment. It provides features such as drag and drop for controls, automatic grid and list support, integrated debugging, Intellisense, and so on.
The installation of Visual Studio .NET comprises several steps:
The Component Update installs the following:
Windows 2000 Service Pack 2, if installing on Windows 2000 (this requires a reboot)
Microsoft Windows Installer 2.0
Microsoft FrontPage 2000 Web Extensions Client
Setup Runtime Files
Microsoft Internet Explorer 6.0 and Internet Tools (this requires a reboot)
Microsoft Data Access Components 2.7
Microsoft .NET Framework
The Component Update install allows you to enter a login name and password to be used during the reboots, so that the entire installation can take place without user interaction.
The Visual Studio .NET install offers a similar setup to previous versions:
Once this step is finished, you have the option of a check for Service Releases, to allow product updates to be automatically downloaded for you.
If you've used previous version of Visual Studio, you may think that the installed menu items are rather sparse, since you only get two or three items (depending upon your installation options). What's noticeable is that the two main items are Microsoft Visual Studio .NET 7.0 and Microsoft Visual Studio .NET Documentation. Because the underlying .NET architecture changes the way languages are used, Visual Studio .NET has been built to take this into account. So, no longer do you pick your language and then run the tool associated with that language. Now you just start Visual Studio .NET and then decide in which language you wish to write, and the type of application to create:
What's great about this, is that the development environment is the same, whatever the language and application. This dramatically reduces training time, as you don't have to learn a different tool to do something differently.
Creating ASP.NET Applications in Visual Studio .NET
When using Visual Studio .NET, you select ASP.NET Web Application from the New Project dialog (shown above), and this creates the named web site and creates some default pages. From that point onwards you just use the design environment to drag controls onto the design grid:
You can then use View Code (or the more familiar double-click on a control) to see the code for the web page you are creating.
We're not going to go into any more detail on using Visual Studio .NET, as it's too big a topic and really is outside the scope of this book. What we really want to concentrate on is ASP.NET itself.
Other Installs
There are several other related technologies that are not included as part of .NET, but which you might find useful. These are:
ODBC .NET Data Provider, which provides access to native ODBC drivers.
Mobile Internet Toolkit, to allow development of sites that support mobile devices, such as phones and PDAs.
Internet Explorer Web Controls, provide a set of client controls (such as a TreeView and Tab Control) for use in Internet Explorer.
Internet Explorer Web Services Behavior.
Not all of these are running to the same timeframe as the .NET SDK, but they should all be available from Microsoft.com/downloads or from MSDN.
How is ASP.NET Different from ASP?
This question can be answered in one word - very. ASP.NET is not just a new version, but a whole new idea and way of programming web applications. New features weren't retrofitted into ASP to give us a new version - ASP.NET has been written from the ground up to provide the best possible application framework. This has meant that, in many areas, compatibility with ASP has been broken, but in the long term this is a good thing. It means that ASP.NET provides a much stronger platform for developing applications, and gives many more benefits.
If you're worried about the compatibility issue, then remember we mentioned earlier that ASP.NET runs alongside ASP. Even though there are many differences between the two, installing ASP.NET won't break existing applications. That's because your existing ASP pages are still processed by the same mechanism as before, and the new framework processes ASP.NET pages. This is achieved by ASP.NET pages having a new file extension (.aspx), meaning they are not processed in the same way as ASP pages.
Compatibility and migration issues are covered in Chapter 23.
(Continues...)
Excerpted from Professional ASP.NET 1.0 by Richard Anderson Brian Francis Alex Homer Rob Howard Dave Sussman Karli Watson 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.