O'Reilly logo

Programming ASP.NET, Second Edition by Dan Hurwitz, Jesse Liberty

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Comparing ASP.NET to ASP

Classic ASP is not event driven in the way that ASP.NET is. To see the difference, consider the following application: you want to open the NorthWind database, supplied with both Microsoft SQL Server and Microsoft Access, and read through the Customers table. For each customer, you want to display the company name, customer ID, the name and title of the contact person, and the phone number. If the contact person is the owner, you want to display the title in red so that it is easy to see.

This example contains a great deal of complexity that will be covered in future chapters, including all the issues surrounding database access, but the fundamentals are straightforward. In classic ASP you would open a connection to the database, perform a query, and get back a RecordSet. You then iterate over the RecordSet, adding each record to an HTML table. If the current record’s ContactTitle column is “Owner,” you set the display to red. The code to accomplish this in classic ASP is shown in Example 3-3.

Example 3-3. Populating a table in classic ASP

<% Response.Expires=0 %> <HTML> <HEAD> <META NAME="GENERATOR" Content="Microsoft FrontPage 4.0"> <META HTTP-EQUIV="Content-Type" content="text/html; charset=iso-8859-1"> <TITLE>List Log</TITLE> <STYLE> BODY,TD, TH {font-family:Verdana;font-size:8pt} .controls {font-family:Verdana;font-size:8pt} #owner {color:red} </STYLE> </HEAD> <BODY> <% dim DBConn, rs set DBConn = Server.CreateObject("ADODB.Connection") DBConn.open ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required