Errata

Programming ASP .NET

Errata for Programming ASP .NET

Submit your own errata for this product.

The errata list is a list of errors and their corrections that were found after the product was released. If the error was corrected in a later version or reprint the date of the correction will be displayed in the column titled "Date Corrected".

The following errata were submitted by our customers and approved as valid errors by the author or editor.

Color key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted By Date submitted Date corrected
Printed
Page 103
Example 5-25

{"Complete Idiot's Guide to a Career in Computer Programming", _
"0789719959"},
should be:
{"Complete Idiot's Guide to a Career in Computer Programming",
"0789719959"},

Anonymous   
Printed
Page 107
Example 5-27

{"Complete Idiot's Guide to a Career in Computer Programming", _
"0789719959"},
should be:
{"Complete Idiot's Guide to a Career in Computer Programming",
"0789719959"},

Page 111 (9/9/02) Second paragraph
Currently: The second ListBox control, with an id of lbMultiple
Should be: The second ListBox control, with an id of lbMulti

Page 129 (5/01/02) Middle of the page, VB.NET translaction of code:
Currently: TableCell cText = new TableCell();
Should be: Dim cText as TableCell = new TableCell()< /P >

Page 129 (8/16/02) The last code example, after "In VB .NET, only this line of code..."
Currently: dim cText as TableCell = new TableCell()
Should be: cText.Width = Unit.Pixel(400)< /P >

Page 142 (8/16/02) In Table 15-19, change the description for _new to the following: Not documented.
Behaves the same as _blank the first time the control is clicked, but subsequent clicks will render
to that same window, rather than open another blank window.

Page 162 (5/01/02) Ex 5-43 (and similarly in 5-44)
ddl_SelectedIndexChanged method.
Currently: cal.VisibleDate = new DateTime(cal.TodaysDate.Year)
Should be: cal.VisibleDate = new DateTime(cal.VisibleDate.Year)

Page 190 (5/01/02) Ex 5-49 Method VisibleMonthChanged. if statement needs a parenthesis.
Currently: if (e.NewDate.Year >...
Should be: if (( e.NewDate.Year >...

Page 196 (5/21/02) Ex 5-50 Method VisibleMonthChanged
Currently has two typos - a double == rather than a single =, and a missing period in e.NewDate
Month:

iIf e.NewDate.Year > e.PreviousDate.Year Or _
((e.NewDate.Year == e.PreviousDate.Year) And _
(e.NewDate Month > e.PreviousDate.Month)) Then
Should be :

iIf e.NewDate.Year > e.PreviousDate.Year Or _
((e.NewDate.Year = e.PreviousDate.Year) And _
(e.NewDate.Month > e.PreviousDate.Month)) Then

Page 215 (5/21/02) Second paragraph on the page, second sentence.
Currently: HttpApplicationState class
Should be: HttpApplication class

Page 223. (5/21/02) Replace first full paragraph with:

Session state is stored in server memory separately from the ASP.NET process. This means that if
the ASP.NET process crashes or is restarted, the session state is not lost. In addition to unplanned
outages, ASP.NET can be configured to periodically perform a preventative restart of each process
after a specified number of requests or after a specified length of time (these is configurable in
machine.config and/or web.config. See Chapter 20 for a complete discussion of configuration.). This
periodic purge greatly improves availability and stability. Session state is preserved even across
these restarts.

Page 253 (5/01/02)
Currently: Protected WithEvents Calendar1 as
Should be : Protected WithEvents Cal as

Page 325
Currently: ValidationExpression="[0-9] {5} | [0-9] {5} - {0-9] {4}"
Should be: ValidationExpression="[0-9] {5} | [0-9] {5} - [0-9] {4}"

Page 327 (5/21/02) C# code at bottom of page. Use code from p. 330.

Page 327 (12/1/02) Replace JavaScript for client-side validation:

<script language="javascript">
function ClientValidator(source, args)
{
if (args.Value % 2 == 0)
args.IsValid=true;
else
aregs.IsValid=false;
return;
}
</script>

Page 343 Comment in example 9-5 [1/9/03]
Currently: <!-- the drop-down which will post back -->
Should be: <!-- the drop-down -->

Page 352, Ex. 10-1 (5/21/02) Replace class Bug with definition on p. 357 - 358.

Page 394 Ex. 10-14. (8/14/02) This code works as shown, but is a bit misleading. The attribute
DataKeyField="bugID" should be DataKeyField="BugID." While it works either way, the upper case
letter will make clear that we are accessing the public property, not the private field.

Page 434 (5/01/02) Last paragraph
Currently: Create a simple Windows Form
Should be: Create a simple Web form

Page 471 (5/01/02) First line on the page
Currently: You can set the Unique property to false...
Should be: You can set the Unique property to true...

Page 486 (5/01/02) Penultimate line on page
Currently: spBugID 2
Should be: spBugHistory2

Page 501-502 (12/28/02) Example 12-2
Currently: SqlDbConnection and SqlDbCommand
Should be: SqlConnection and SqlCommand

Page 503 (5/01/02)
Currently: The return value is the is the number of records affected, which you pass back to the
calling program.
Should be: The return value of ExecuteNonQuery is the is the number of records affected.

Anonymous   
Printed
Page 504
1st paragraph and code

NOW READS: You pass this cmd string to the UpdateDB method as described previously,
and then you update the label with the number of rows affected. Finally, you call
BindData, which rebinds the data grid with data from the database, and updates the
label to display your progress.

int numRowsAdded = UpdateDB(cmd);

lblMessage.Text = "Added " + numRowsAdded.ToString( ) + " rows.";
BindData( );

SHOULD READ: You pass this cmd string to the UpdateDB method as described previously.
Finally, you call BindData, which rebinds the data grid with data from the database.

UpdateDB(cmd);
BindData( );

Page 509 (5/01/02) Last paragraph. Currently :

...drag a RadioButtonList control onto the form and then drag two RadioButton controls on top of it.
Label one of the buttons DB Transacation and label the second button Connection Transaction, as
shown in Figure 12-4.
Should be:
...drag a RadioButtonList control onto the form.
You add the buttons by setting properties, as explained at the top of page 510.

Page 523 bottom of the page. Please replace the last two lines of code with:

// make a data adapter (default constructor)
SqlDataAdapter dataAdapter = new SqlDataAdapter();
// make a connection object (pass in connection string)
SqlConnection conn = new SqlConnection(connectionString);
// make a command object, passing in command string and connection object
SqlCommand cmd = new SqlCommand(commandString, conn);

Page 532-535 Stored Procedures. PLease change spDeletebugFromDataSet to the following

CREATE PROCEDURE spDeleteBugFromDataSet
@BugID int
AS
DELETE FROM BugHistory WHERE BugID = @BugID
DELETE FROM Bugs WHERE BugID = @BugID
GO

The intention was not to have BugHistoryID be an identity field, but rather to assign these values
manually. Since BugHistoryID is an identity field, however, it is not possible to have more than
one BugHistory record with the same BugHistoryID, and thus you are safe updating and deleting
without regard to the BugID.

Anonymous   
Printed
Page 539
2nd paragraph

Book Text:
"Set Welcome.aspx as the start page."

How?

Page 563 (5/01/02) Ex 12-15 Try block. Add the following as the first line in the Try block.
AddHandler myDataAdapter.RowUpdated, AddressOf OnRowUpdate

Page 658 (and 659)
Currently: output.Write( "<TR><TD colspan = '2'> align='center'" );
should be: output.Write( "<TR><TD colspan='2' align='center'>" );

Page 697 (5/01/02) Example 16-17, 16-23. Change variable name from stock to theStock

Page 754 (11/4/02) Replace the first paragraph with the following:
Cached pages or portions of pages are stored in memory. Subsequent
requests for the same page or portion of page are fulfilled directly
from memory, rather than recreated by the page's program logic. Since
memory is a limited resource, output caching must be used carefully to
avoid scaling problems.

Page 754 (11/4/02) Replace the paragraph under the Object Caching heading:
Object caching is the caching of objects on the page, such as data bound
controls. Object caching also stores the cached data in server memory,
and so must be used carefully to avoid scaling problems.

Page 759 (11/4/02) - Paragraph under Location heading
Currently: hard drive
Should be: machine

Page 777 (8/16/02) Examples 18-15 and 18-16 require the following Import directives in order for
the pages to properly compile and run:
Import namespace="System.Data"
Import namespace="System.Xml"

Page 809 (5/01/02) Bottom of the page, remove the last paragraph and code snippet

Page 821 (11/6/02) Example 19-3 is not shown in VB.NET. Here is the code:

if CheckCredentials(txtUserName.Text, txtPassword.Text) then
' Do stuff if authenticated
else
' Do stuff if notauthenticated
end if

private function CheckCredentials(username as string, password as
string) as Boolean
' Do a database or XML lookup to see if the username and
' password are valid.
' If valid, then return true, otherwise return false.
end function


Page 834 Second paragraph under the heading Impersonation, which begins with "By default, ..."
should be replaced with the following paragraph:

By default, ASP.NET processes run with a userName of "machine" (note all lowercase). This causes
the processes to run under a special low privilege user account named "ASPNET", which is created
when the ASP.NET is installed. It is also possible to change the value of userName to "SYSTEM",
which gives the processes full access to all resources, or to any valid username which is a member
of a domain which has sufficient access rights to the web server. If there is a security breach,
then a malicious user may be able to run processes with the same access to resources provided by
the userName assigned to the ASP.NET processes.

Page 834 Third paragraph under the heading Impersonation, the next to last and last lines, which
currently read "not SYSTEM." should be modified to read "not the username specified as as running
all ASP.NET processes."

Page 835 Under the heading Application Identity, the first sentence should be modified to read:
As stated earlier, the default identity for ASP.NET is "machine".

Page 835 The code snippet with the default processModel section from machine.config has an error.
The default value of userName should be "machine" (note all lowercase) rather than "SYSTEM".

Pages 835 - 836 The last paragraph of p. 835 and the first two paragraphs of p. 836 should be
modified to read: The relevant attributes here are userName and password. There are two special
values for userName: SYSTEM and machine (note all lowercase). The default is machine. In either
case the value for password needs to be AutoGenerate, which forces the system to create its own
password. As mentioned above, when ASP.NET assumes the username SYSTEM, it has full access to all
resources. The default value of userName, machine, will cause the process to run using a special
account, installed automatically when ASP.NET is installed, called ASPNET. This account is a member
of the Users group, which is prevented from making system-wide changes.

Page 886 Example 20-18 (6/14/2002)
Currently: <section name = "altDB" type="System.Configration.NameValueSectionHandler, System" />
Should be: <section name = "altDB" type = "System.Configuration.NameValueSectionHandler, System,
Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, Custom=null" />
Note: for further documentation, check sdk documentation, search on Custom Elements and choose
Custom Element for NameValueSectionHandler.

Page 878, after code snippet for processModel, please add this:Two of these attributes are worth
special mention, since they can improve the stability of the system. The timeout attribute controls
how often every process is automatically shut down and restarted. The default value is "Infinite",
indicating that the process is never restarted. It may also have a time value of the form hh:mm:ss.
So for example, if you want every process to restart every 20 minutes, use the value "00:20:00".
The requestLimit attribute specifies how many requests each process can receive before it is re-
started. The default value is also "Infinite". Typical values would be an integer inside quotes.
So to restart every process every 5000 requests, use the value "5000".

Page 875 (5/21/02) The last paragraph under pages, describing the AutoEventWireup attribute is
incorrect. It should be replaced with the following paragraphs:

When AutoEventWireup is true (the default value outside of VS.NET), then the .NET Framework calls
page events (Page_Init & Page_Load) automatically, with no code necessary to explicitly add an event
handler to an event delegate.

If AutoEventWireup is false (the default when using VS.NET), you must explicitly add event handler
methods to the event delegates. VS.NET does this for you.

Anonymous