Errata

Programming Microsoft® ASP.NET MVC

Errata for Programming Microsoft® ASP.NET MVC

The errata list is a list of errors and their corrections that were found after the product was released.

The following errata were submitted by our customers and have not yet been approved or disproved by the author or editor. They solely represent the opinion of the customer.

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

Version Location Description Submitted by Date submitted
PDF Page xviii
Last two paragraphs

In reality, this is not an error. In the "Hardware and Software Requirements" exists another softwares that can be used to work with the code of the book. Some of this softwares was not released when the book was able to be printed.

More options for operating systems:
- Windows Server 2003 SP2/R2 (all editions)
- Windows Server 2008 R2 (all editions)

More options for Visual Studio IDEs:
- Microsoft Visual C# 2010 Express, and Microsoft Visual Web Developer 2010 Express

More options for SQL Server:
- SQL Server 2005 (all editions, including free SQL Server 2005 Express Edition)
- SQL Server 2008 SP1 (all editions, including free SQL Server 2008 SP1 Express Edition)
- SQL Server 2008 R2 (all editions, including free SQL Server 2008 R2 Express Edition)

For Visual Studio 2008 users, it is important to cite that will be necessary to install the "ASP.NET MVC 2 RTM" on top of existing ASP.NET 3.5 SP1 runtime: http://www.microsoft.com/downloads/details.aspx?FamilyID=c9ba1fe1-3ba8-439a-9e21-def90a8615a9&displaylang=en.

Regards,

Rog?rio Moraes de Carvalho

  May 08, 2010 
PDF Page 5
3rd paragraph (Note)

The author uses "Personal Home Page" acronym to describe PHP.

But, now PHP stands for PHP: Hypertext Preprocessor. This confuses many people because the first word of the acronym is the acronym. This type of acronym is called a recursive acronym.

This explanation can be found at http://www.php.net/manual/en/faq.general.php#faq.general.acronym.

In 1995, Rasmus Lerdorf named "Personal Home Page" Tools.

With the launch of PHP 3.0, in June 1998, it was named plain "PHP", with the meaning being a recursive acronym - PHP: Hypertext Preprocessor. See the history of PHP at http://www.php.net/manual/en/history.php.php.

  May 09, 2010 
PDF Page 8
4th paragraph of "Engineering Current Best Practices" topic

The classic ASP code bellow:

<input name="TextBox1" type="text" value='<% Request.Form["TextBox1"] %>' />

Must be:

<input name="TextBox1" type="text" value='<%= Request.Form["TextBox1"] %>' />

<%= ... %> is equivalent to <% Response.Write(...) %>

Rogerio Moraes de Carvalho
Twitter: @rogeriomc

  May 09, 2010 
PDF Page 10
4th paragraph

This is not an error report, but only a suggestion.

Follow the code to the Button1.Click event in the book:

public void Button1_Click(object sender, EventArgs args)
{
// Sets the label to display the content of the text box
Label1.Text = "The textbox contains: " + TextBox1.Text;
}

The code is functional, but if the user uses the Visual Studio IDE to generate the click event handler, it will be marked as protected, not public. The public modifier does not invalidate the code, but it is not a good practice expose the method handler publicly.

  May 09, 2010 
PDF Page 11
Last paragraph

"In an ASP.NET page, any user action (such as clicking or changing the current selection) originates a postback."

Server click events originates a postback, but server change events only originates a postback if the AutoPostBack boolean property is true. The default value is false.

The affirmation that "any user action" originates a postback is not so real. The truth is that most client-side events are not translated to server-side events. For example, the onmouseover client-side event.

  May 09, 2010 
PDF Page 12
2nd paragraph of the "The HTTP Handler" topic

The following book code is invalid in C#:

public interface IHttpHandler
{
public void ProcessRequest(HttpContext context);
public bool IsReusable;
}

The correct code must be:

public interface IHttpHandler
{
void ProcessRequest(HttpContext context);
bool IsReusable { get; }
}

Notes:
- In C#, the modifier 'public' is not valid for interfaces.
- In C#, interfaces cannot contain fields. In that case, IsReusable is a read-only property, not a field. The correct is showed above.

  May 09, 2010 
PDF Page 12
Last but one paragraph

"Each page consists of two files: an .aspx markup file describing the expected HTML template and a C# (or Visual Basic) class file that contains postback handlers and any ancillary methods."

This is the main choice for Web Forms pages: an markup code for the interface (.aspx), and a class page for code-behind (.aspx.cs or .aspx.vb). But, it is possible to mix markup code with the Page class code in only one .aspx page.

  May 09, 2010 
PDF Page 13
Figure 1-2

"Postback" appears in the figure as an event of the page life cycle, but it isn't.

The following list shows the page life-cycle events that you will use most frequently:
- PreInit
- Init
- InitComplete
- PreLoad
- Load
- Control events
- LoadComplete
- PreRender
- PreRenderComplete
- SaveStateComplete
- Render
- Unload
More information: "ASP.NET Page Life Cycle Overview": http://msdn.microsoft.com/en-us/library/ms178472.aspx

The "Your code-behind class" box in the figure omits the "class" keyword.

The following code is in the book:
public _Default : System.Web.UI.Page
{

}

The following code corrects the book's code:
public class _Default : System.Web.UI.Page
{

}

Note: Since ASP.NET 2.0, the code-behind class use the"partial keyword modifier.

  May 09, 2010 
PDF Page 14
4th paragraph

"Any customization is possible only in the code-behind class of a page."

Actually, a customization is possible in a user defined class. It can inherit the System.Web.UI.Page class, for example. In this case, some pages can inherit directly from the user defined page class.

  May 09, 2010 
PDF Page 14
Last paragraph

Book's fragment:
"Such a dynamically created class inherits from the code-behind class (thus grabbing the desired behavior), and all it does in the constructor is parse the associated markup file for runat-flagged elements and populate the Controls collection of the parent Page class with instances of server controls."

The code-behind file contains the complete class declarations in the default namespace. However, the class is declared with the partial keyword, which indicates that the class is not contained entirely in one file. Instead, when the page runs, the compiler reads the .aspx page and the file it references in the @ Page directive, assembles them into a single class, and then compiles them as a unit into a single class.

Ie, the dynamically created class, from .aspx page, does not inherit from the code-behind class.

More information: "ASP.NET Web Page Code Model" - http://msdn.microsoft.com/en-us/library/015103yb.aspx

  May 09, 2010 
PDF Page 15
1st paragraph of the "Page Hierarchies" topic and figure 1-3

The same error described previously in the location "Page 14 - Last paragraph".

  May 09, 2010 
PDF Page 19
1st paragraph

"A server control is a black-box component that, when declaratively or programmatically configured, ends up outputting HTML and JavaScript for the browser."

Server controls ends up outputting CSS, too.

You can control the look of ASP.NET server controls by setting various appearance properties such as ForeColor, BackColor, Height, and Width. In addition, some controls support style objects that expose additional style-related settings.

  May 09, 2010