Skip to main content

Beginning ASP.NET 1.1 with VB.NET 2003

Beginning ASP.NET 1.1 with VB.NET 2003

Chris Ullman, John Kauffman, Chris Hart, David Sussman

ISBN: 978-0-764-55707-1

Jan 2004

888 pages

Select type: Paperback

Product not available for purchase

Description

What is this book about?

This book teaches you how to build custom ASP.NET Web sites from the ground up. An expert team of authors uses their extensive ASP.NET programming experience to give you hands-on instruction in the best way to create Web sites with ASP.NET. This completely updated edition features new examples, and all code is written and tested for ASP.NET version 1.1.

What does this book cover?

Here's what you will learn in this book:

  • How to install and configure ASP.NET
  • Basic programming principles for Visual Basic. NET, such as variables, controls structures, and procedural programming
  • Techniques for applying these principles as you develop ASP.NET pages
  • The minimum amount of object-oriented programming necessary to work successfully and efficiently with ASP.NET
  • Key differences between ASP.NET 1.0 and 1.1, how to use the examples in this book with either version, and how to move from 1.0 to 1.1
  • Build ASP.NET sites faster using Microsoft's new, free WebMatrix tool
  • Techniques for extending your ASP.NET sites to incorporate related tools and technologies, such as using ADO.NET for data source access
  • Web Services for inter-Web site communication, and Server Controls for facilitating code maintenance and reuse
  • How you can make your ASP.NET site production-ready through proper debugging, optimization, and security

Who is this book for?

This book is for beginners who have no previous experience of ASP, VB, XML, object-oriented programming, or the .NET framework. A little knowledge of HTML is useful, but not essential. All the concepts you need to create dynamic ASP.NET Web sites are presented and explained in full.

Introduction.

Chapter 1: Getting Started with ASP.NET.

Chapter 2: Anatomy of an ASP.NET.

Chapter 3: Server Controls and Variables.

Chapter 4: Control Structures and Procedural Programming.

Chapter 5: Jumping Structures – Subroutines and Functions.

Chapter 6: Event-Driven Programming and Postback.

Chapter 7: Objects.

Chapter 8: Reading From Databases.

Chapter 9: Advanced Data Handling.

Chapter 10: ASP.NET Server Controls.

Chapter 11: Users and Applications.

Chapter 12: Reusable Code for ASP.NET.

Chapter 13: .NET Assemblies and Custom Controls.

Chapter 14: Debugging and Error Handling.

Chapter 15: Configuration and Optimization.

Chapter 16: Web Services.

Chapter 17: ASP.NET Security.

Appendix A: Exercise Answers.

Appendix B: Web Matrix Quick Start.

Appendix C: The Wrox United Database.

Appendix D: Web Application Development using Visual Studio .NET.

Appendix E: Installing and Configuring IIS.

Index.

Code Downloads
Code downloads for this title are available here.
Download all the code samples for the book - updated 10/14/2004.
Download
Download a SQL Server version of the Wrox United example database.
The complete code download for the book includes an Access version of the Wrox United example database. This separate download is a SQL Server version of the same Wrox United example database.
Download
Replacement for Figure 9-3
Download
Tutorial referenced on page 476, chapter 13
Download
Chapter 13 replacement exercises for page 511
Download
Replacement for Figure 14-23
Download
Replacement for Figure 14-24
Download
Replacement for Figure 16-17
Download
ChapterPageDetailsDatePrint Run
123Missing "to" in sentence
Step 3 should read: "The installation process will continue without requiring further intervention, although you may have to reboot the system afterwards. Once MDAC is installed, you are ready to install ASP.NET.
9/3/04

129Additional configuration directions

The configuration directions as written cause Web Matrix to use Framework version 1.1, but you also need to configure the Web server Cassini to use Framework version 1.1 or you could have problems when you use a DLL created in WebMatrix version 1.1 but try to run a Web form against the server using Framework 1.0. Specifically, without this fix you might encounter this problem in chapter 16. To correct this, replace step 4 on page 29 with these new steps 4 to 6.

4. Save the file.

5. Next you need to create a new text file with the name WebServer.exe.config and add the following code:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v1.1.4322" />
</startup>
</configuration>

If the file already exists then all you need do is insert the <startup> and <supportedRuntime> tags between the <configSection> and <runtime> tags as you did with WebMatrix.exe.config.

6. Save the file and when you run Web Matrix, the .NET Framework version should now be 1.1.x. Select the "About ASP.NET Web Matrix..." item from the Help menu. It should confirm this.

12/11/031

129Missing text in file name in Step 1
Step 1 should read: Go to Program Files\Microsoft ASP.NET Web Matrix\v0.6.812 and run Web Matrix. The screen that appears is shown in Figure 1-13:
9/3/04

136Typo in Step 1 New Files should be New File
The second sentence should read: Then select New File from the File menu and in the dialog change the Location and Filename details as shown in Figure 1-23:
9/3/04

142Typo in 2nd bullet in url after word or
The url after the word "or" should be: ...or http://localhost/ch02/punctual.aspx....
Not .../ch01/...
9/3/04

261Missing GrocerToGo.mdb file
The GrocerToGo.mdb file is not part of the book, but part of the .NET Framework examples AFAIK.
Search Google for grocertogo.mdb and Download, and I think you should be able to find it. You may even have it already somewhere on your system....
2/19/04

7219Last paragraph, 2nd sentence
Should read: Unlike variables, where the Dim statement defines a class, only the Class keyword followed by the class name (in this case, Person) has been used. The keyword, Public means that the class will be available to all other programs. This is necessary, as an ASP.NET page will use it.
10/14/04

72251st line in step 4
From the Page_Load method, take out the line that sets the EyeColor and modify the class constructor so it looks like the following:
10/14/04

72254th paragraph under "How It Works"
The New keyword specifies that the object is being created, and therefore causes the constructor to be run. Also, because the property is now read only, the line that explicitly sets the eye color has to be removed:

myPerson.EyeColor = "Blue"
10/14/04

72274th line on page
A method is simply a Public Function or Public Sub within the class, and follows the same rules for those as discussed in Chapter 5 so we don't need to cover the basics again.
10/14/04

72271st line in step 1
Edit the FirstClass.aspx file, and remove the text and labels from the HTML <form runat="server"> section.
10/14/04

72282nd line in step 4
Should be: You'll see a simple display that shows the name of the person and the direction they are traveling in, as shown in Figure 7-4:
10/14/04

72301st text paragraph, 2nd sentence
Should be: A value greater than 0 is taken as traveling forwards, and a negative number as traveling backwards:
10/14/04

82532nd bullet in bulleted list
Should be: Speed: Stored procedures are optimized the first time they are called, and then the optimized code is used in subsequent calls.
10/14/04

82571st line of code
Should be: <wmx:AccessDataSourceControl id="AccessDataSourceControl1"
10/14/04

82581st two lines of code in code block
Should be: <wmx:MxDataGrid id="MxDataGrid1" runat="server"
DataSourceControlID="AccessDataSourceControl1" BorderColor="#CCCCCC"
10/14/04

82591st two lines of code in code block
Should be: <wmx:MxDataGrid id="MxDataGrid1" runat="server" DataSourceControlID="AccessDataSourceControl1">
10/14/04

82661st sentence in step 3
Should be: Pick the SELECT Data Method and drag it from the Toolbox, dropping it into your code window (make sure that where you drop the toolbox item is outside any existing procedures):
10/14/04

82702nd sentence under "How It Works"
This is great if you are a newcomer to SQL as you don't have to understand how the SQL language works.
10/14/04

82735th text paragraph, 3rd sentence
Should be: – This is on the first screen and is the same as the Data Explorer allowing you to pick either Access or SQL Server database.
10/14/04

82772nd table, 1st description for metod "ExecuteNonQuery"
Should be: This executes the command but doesn't return any rows of data. It is useful for commands that perform an action, such as updating data, but that don't need to return a set of data. A value is returned, indicating the number of rows affected by the command.
10/14/04

82801st paragraph after figure 8-22, 2nd sentence
First you've used two controls that are bound to data – the list of categories and the grid of products.
10/14/04

82831st paragraph, 1st sentence under "The DataReader Object" heading
The DataReader, an object that we haven't come across yet, is optimized for reading data.
10/14/04

92883rd to last line & last line in code block
3rd to last line should be: dataAdapter.Fill(data)

Last line should be: dataAdapter.Fill(data)
10/14/04

92892nd code block & addtional text and code block

2nd code block should be:

dataAdapter.Fill(data, "Products")
dataAdapter.SelectCommand.CommandText = "SELECT * FROM Employees"
dataAdapter.Fill(data, "Employees")

Additional paragraph and code block after 2nd code block should be:

The problem is that this code doesn't work as expected, because IDbDataAdapter doesn't accept the table name as an argument. For this to work you have to use the actual class, OleDbDataAdapter, rather than the interface:

Dim dataAdapter As System.Data.OleDb.OleDbDataAdapter = _
   New System.Data.OleDb.OleDbDataAdapter
dataAdapter.SelectCommand = dbCommand
Dim data As System.Data.DataSet = New System.Data.DataSet
dataAdapter.Fill(data, "Products")

10/14/04

9291Step 4, 2nd sentence
Should be: Also drag two the Label controls onto the page and position them as headings to show the contents of selected items from the Datagrid controls.
10/14/04

9292Error in Figure 9-3
Replacement Figure 9-3 can be downloaded on the download page.
10/14/04

92993rd code block, 1st line
Should be: DataGrid2.DataSource  =  table
10/14/04

93002nd paragraph & 1st code block
Should be:
Finally we update the data for the selected row. There could be many rows returned by the Select() method, so we index into the array. In our case we know that there is only one row returned – at at most one row. We check the Length of the SelectedRows array to make sure that at least one row was found, as trying to update the row would fail if nothing was found.:
If SelectedRows.Length > 0 Then
   selectedRows(0).Item("FirstName") = "John"
   selectedRows(0).Item("LastName") = "Hartford"
End If
10/14/04

93006th code block, 1st line
Should be: DataGrid3.DataSource = table
10/14/04

93011st code block, 1st line
Should be: DataGrid4.DataSource = table
10/14/04

9302Additional line to code block
1st line should be: <%@ Page Language="VB" %>
10/14/04

9310Add to beginning of code block
If txtFirstName.Text.Trim() = " Or _
   txtLastName.Text.Trim() = " Then
   Return
End If
10/14/04

93122nd code block
Should be:
Dim commandString As String = _
   "INSERT INTO Employees(FirstName, LastName) " & _
   "Values(@FirstName, @LastName)"
10/14/04

93124th code block, 5th line
Should be: lastNameParam.Value = txtLastName.Text
10/14/04

93125th code block
Should be:
If dbCommand.ExecuteNonQuery() > 0 Then
  lblStatus.Text = "Data was added successfully"
Else
  lblStatus.Text = "Data could not be added"
End If
10/14/04

13476Tutorial referenced is missing
Can be found on the download page
12/1/04

13511Replacement exercises for 1-4
Replace exercises 1-4 completely with exercises 1-5 in the file 57076_ch13_Exercises.doc on the download page.
9/17/04

14516Last 2 lines
DepostAmount should not be broken
9/17/04

14517Corrections in Table
Cbool should be CBool
Cbyte should be CByte
Cchar should be CChar
Cdate should be CDate
Cdec should be CDec
Cint should be CInt
Cobj should be CObj
9/17/04

145171st line of code in the code following the table at the bottom of the page
Condtion should be Condition
9/17/04

14520Step 1, 1st line
Should be: Open Web Matrix and create a new file called syntaxerror.aspx and type the following lines of code into the All Window.
9/17/04

14520Step 2, first line
Should be Save this file and load the file using a browser. (Delete "as syntaxerror.aspx")
9/17/04

145244th line of code block in step 1
Should be:
Else If CInt (txtQuantity.Text) <= 0 Then
9/17/04

145321st line, last paragraph on the page
Should be:
Setting the Debug mode at the application level will display...
9/17/04

145392nd line in 2nd paragraph under Application-Level Tracing heading
2nd sentence should be:
For instance, if tracing is enabled at the application level but disabled for a page,...
9/17/04

14539Error in 3rd line in 2nd code block
Should be:
<trace enabled="true" requestLimit="10" pageOutput="false"
9/17/04

14541Step 1, 1st sentence on 2nd line in text
1st sentence should be:
Open Web Matrix, create a new file called unstructurederror.aspx, and then replace the existing code in the Code Window with the following:
9/17/04

14543Try It Out heading
Heading should be:
Try It Out Using On Error Goto
9/17/04

145442nd & 3rd paragraphs
In the 2nd paragraph, in the 2nd sentence, and the 3rd paragraph, in the 1st & 2nd sentences, On Error should be On Error Goto.
9/17/04

14557Error in Figure 14-23
Replacement Figure 14-23 can be downloaded on the download page.
9/17/04

14558Error in Figure 14-24
Replacement Figure 14-24 can be downloaded on the download page.
9/17/04

14558Error in 1st code block, 1st line
Code should read <customErrors defaultRedirect="userError.aspx" mode="On">
9/17/04

155702nd line
Delete "Special Edition"
9/17/04

155715th paragraph, 4th line
"...find Webserver.exe.config that..." should be "...find WebServer.exe.config that..."
9/17/04

15576Last code block missing code
Last part of code should be:
userControlBaseType="[typename]"//Default: System.Web.UI.UserControl
validateRequest="[true|false]"       // Default: true
-->
<pages buffer="true" enableSessionState="true" enableViewState="true"
  enableViewStateMac="true" autoEventWireup="true" validateRequest="true"
/>
9/17/04

15576Last paragraph, 1st sentence
Sentenced should be:This should give you a reasonable idea as to how each of the settings work, and how they may be specified.
9/17/04

15577Error in code block at bottom of page
Should be:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.web>
   <compilation />
   <customErrors />
   <authentication />
   <authorization />
   <trace />
   <sessionState />
   <globalization />
  </system.web>
</configuration>
9/17/04

15578Last line, bottom of page
Delete "Special Edition"
9/17/04

155791st character in each of the last 3 bullets in bullet list & 4th line of 3rd bullet
Should not be capitalized. Should be: enableSessionState, enableViewState, enableViewState, and autoEventWireup respectfully.
9/17/04

15584Last bulltet on page
Should be:
VaryByHeader enables you to cache pages specified by different HTTP headers, using a semicolon-separated list of strings.
Delete the 2nd sentence.
9/17/04

15590Code line before 2nd bulleted list
Should be:
Cache.Insert (FileName, Object, Dependency, DateTime, TimeSpan)
9/17/04

155851st bullet on page
Replace current bullet with:
VaryByParam enables you to cache sections of the page according to a list of parameters, which are also supplied as a semi-colon delimited list of strings. These strings will either be a query string , or a parameter sent via the POST() method. The permissible values include none,*, or any valid query string or POST() parameter name. You must include this attribute whenever you output cache an ASP.NET page or user control, because a parser error will result otherwise. To ensure the entire page is cached, just set the value to none. The "*" (asterisk) setting specifies that the Output Cache should hold a version of the page for every parameter property that your control returns.
9/17/04

155902nd bullet in 2nd bulleted list
Should be:
Object specifies the name of the object, most typically a DataSet.
9/17/04

155931st line of code after step 4
Should be:
<?xml version="1.0"?>
9/17/04

15594Error in 5th (next to last) code block
First line should be:
grid1.DataSource = nothing
9/17/04

155955th text paragraph, 3rd line
("address") should be ("addressKey")
9/17/04

15596First character in the 6th line of the code block
MyLabel1.Text="Cache Full" should be myLabel1.Text="Cache Full"
9/17/04

155956th text paragraph
Let's transperse this code into a fully working example.
Should be:
Let's integrate this code into a fully working example.
9/17/04

155981st character in the 2nd line of the 3rd code block
MyLabel1.Text="Cache Full" should be myLabel1.Text="Cache Full"
9/17/04

15599Code block under heading "Cache Priorities"
2nd line should be:
TimeSpan.Zero, CacheItemPriority.High )
9/17/04

166083rd Code block, 2nd and 3rd lines
Should be:
< WebMethod (Description:="Returns a greeting using the name passed in")> _
Public Funtion Hello(ByVal Name As String) As String
9/27/04

16610-611Paragraph below HTTP Post heading
Should read:
HTTP POST
By default though when you send a web service, you will be using HTTP POST, which uses the body of the Request to carry the name-value pairs. You can retrieve these values using the Request.Form collection in ASP.NET. If you use the POST method to send the information, it means that the information isn't visible in the URL. This provides a slightly more secure method, since it is possible to manipulate the name-value pairs when using the GET method, by just typing names and values into the query string in the address bar.
9/27/04

166242nd code block, 2nd line
LibraryConn should start a new line.
9/27/04

166251st paragraph, 2nd and 3rd lines
BookDetails should be BookDetail
9/27/04

16634Replacement Figure 16-17
Replacement Figure 16-17 can be downloaded on the download page.
9/28/04

16643Code block at top, last line of step 1
0 should not be there.
9/27/04

176694th text paragraph, 3rd and 4th lines
3rd line: "C:\BegASPNET11\" should be "C:\BegASPNET11\Ch17\" 4th line: "C:\BegASPNET11\admin" should be "C:\BegASPNET11\Ch17\admin"
9/27/04

176711st line in step 1
"the" is duplicated
9/27/04

17671Code block following Step 1
Additional code lines between <configuration> & <system.web>

<appSettings>
                    <add key="ConnectionString" value="Provider=Microsoft.Jet.OLEDB.4.0;
Ole DB Services=-4; Data
Source=C:\BegASPNET11\ch17\WroxUnited\Database\WroxUnited.mdb"/>
       </appSettings>

        <system.web>
9/27/04

17672Step 4 text
Should read: Add the following code in the Web Matrix Code window (this is where the code behind goes):
9/27/04

17672Step 4 Code block, 2nd code line
Should be:
Dim PlayersDB as System.Data.IDataReader
9/27/04

176731st code block, 1st line
Should be:
System.Data.OleDb.OleDbConnection(connectionString)
9/27/04

176731st code block, 15th line
Should be:
[Players].[SitePassword],[Players].[AdminLevel] FROM [Players]"
9/27/04

176731st code block, 3rd line from bottom of block
Should be:
dbCommand.ExecuteReader( System.Data.CommandBehavior.CloseConnection )
9/27/04

176772nd line in Step 11
Should read: "You're redirected back to the default.aspx page."
9/27/04

176795th text paragraph, 1st line
Should read: "During this subprocedure, we call the IDataReader function."
9/27/04

176802nd code block, 1st line
Should read: "lblStatus.Text = "<br>You are logged in as: " & Request.Cookies ("User NameCookie").Value"
9/27/04

17680Last text line
Should read: "Then as we no longer want the user to be logged in, we dump them unceremoniously back at the default.aspx page:"
9/27/04

17682Code block with step 1
Should be:
<configuration>
<appSettings>
             <add key="ConnectionString" value="Provider=Microsoft.Jet.OLEDB.4.0;
Ole DB Services=-4; Data
Source=C:\BegASPNET11\ch17\WroxUnited\Database\WroxUnited.mdb"/>
</appSettings>
    <system.web>
     <authentication mode="Forms">
       <forms name=".WroxDemo2" loginUrl="login.aspx"
       protection="All" timeout="20"
      requireSSL="true" />
     </authentication>
     <authorization>
       <deny users="?" />
     </authorization>
   </system.web>
</configuration>
9/27/04

Appendix A7361st line of Excercise 2 Solution
Should read: The following setion should go in web.config in the ch15 folder.
9/24/04

Appendix A736Last Line of 1st code block in Exercise 3 Solution
Should read:<12:mylabel12 text="ServerTime()" runat="server"/>
9/24/04

Appendix A7381st line of code block in Exercise 4 Solution
Should be: <%@ WebService Language="VB" Class="Circles"%>
9/24/04

Appendix A739Mid way through Exercise 5 code block Solution
Should be:
NET11\ch16\Northwind.mbd;"
9/24/04

Appendix A743Exercise 2 Solution 2nd code block, 14th code line
Should be: <br />Zip:|<br />
9/24/04

Appendix A743Exercise 3 Solution code block, 4th line from bottom of page
Should be: txtEmail.Text & "'" & "AND ZipCode = '" & txtZipCode.Text & "'"
9/24/04

What is this book about?

This book teaches students how to build custom ASP.NET Web sites from the ground up. An expert team of authors uses their extensive ASP.NET programming experience to give you hands-on instruction in the best way to create Web sites with ASP.NET. This completely updated edition features new examples, and all code is written and tested for ASP.NET version 1.1.

What does this book cover?

Here's what students will learn in this book:

  • How to install and configure ASP.NET
  • Basic programming principles for Visual Basic. NET, such as variables, controls structures, and procedural programming
  • Techniques for applying these principles as you develop ASP.NET pages
  • The minimum amount of object-oriented programming necessary to work successfully and efficiently with ASP.NET
  • Key differences between ASP.NET 1.0 and 1.1, how to use the examples in this book with either version, and how to move from 1.0 to 1.1
  • Build ASP.NET sites faster using Microsoft's new, free WebMatrix tool
  • Techniques for extending your ASP.NET sites to incorporate related tools and technologies, such as using ADO.NET for data source access
  • Web Services for inter-Web site communication, and Server Controls for facilitating code maintenance and reuse
  • How you can make your ASP.NET site production-ready through proper debugging, optimization, and security

Who is this book for?

This book is for beginners who have no previous experience of ASP, VB, XML, object-oriented programming, or the .NET framework. A little knowledge of HTML is useful, but not essential. All the concepts you need to create dynamic ASP.NET Web sites are presented and explained in full.