DevCity.NET - http://devcity.net
Book Review: Murach's ASP.NET 2.0 Web Programming With C#
http://devcity.net/Articles/222/1/article.aspx
Scott Waletzko

Scott Waletzko has been an Information Technology professional and Windows / Web programmer since 1995, with experience in software development and architecture, network design and administration, and project and team management. Currently he is the the Senior Vice President of Technology at Intellisponse, as well as the President of Skystone Software / Echosoft Design Studios, LLC.

At Intellisponse, Scott is responsible for architecture and implementation of the company flagship software called Synapse, the first full-featured Web survey authoring tool for market research, enabling researchers to design, publish, and manage full-featured and logically complex questionnaires to the Internet without programmer interaction.

As president of Skystone Software / Echosoft Design Studios, LLC, Scott is developing a unique Web site content management system named Tempest, which will drive myBard.com and provide comprehensive Web site hosting and content management to anyone with a Web browser.

 
by Scott Waletzko
Published on 5/2/2006
 

     

A review of Murach's ASP.NET 2.0 Web Programming With C# tutorial and reference book, written by Scott Waletzko (Skystone Software).


Overview

ASP.NET 2.0 Web Programming With C#, written by Joel Murach and Anne Boehm, is a comprehensive tutorial that walks the reader through the basics of virtually every aspect of Web site programming in ASP.NET 2.0. The first half of the book is dedicated in part to programmers new to Web programming in general, or new to Web programming ASP.NET. The second half of the book delves deeper into more professional Web development techniques such as database access, SSL, user authentication and profiles, and even touching on Web services and reusable Web component design. Throughout, the authors do a good job of pointing out features that are new or specific to .NET 2.0, which makes this a valuable reference even for programmers with extensive ASP.NET development experience.

For every two pages in the book (it weighs in at nearly 900 pages) the content is repeated once in classic Murach style; the left-hand page is a detailed description of the concept being covered written in a conversational tone, and the right-hand page contains a recap of this discussion in bulleted-form, with screenshots and / or code samples. This layout is ideal for both novice and expert readers alike; beginners learn faster when a concept is restated / repeated, and experts can skim through the right-hand pages looking for content that is new to them.

The authors assume that the reader has a working knowledge of C# syntax (there is a VB version as well), but pretty much everything else involved in Web site development using ASP .NET 2.0 is explained in detail.

 

Walkthrough: Sections 1-3

The first four chapters of the book ("Section 1 - The essence of ASP.NET web programming") are designed to get programmers new to ASP.NET development up and running and hands-on. In these pages, the reader is introduced the basics of Web site development ("How static web pages work", "How dynamic pages work"), to the example Web site that is used throughout the rest of the book (an online Halloween superstore), and to the .NET Framework and Visual Studio integrated development environment. Much of what is mentioned in these chapters is covered in detail later on in the book. While much of this section feels like it is rushing the user through concepts, the rest of the book is written in a very leisurely manner and gets into quite a bit of detail on each topic.

In fact, anyone with any experience programming with ASP.NET may want to skip the first section and start right in with "Section 2 - Basic ASP.NET skills". These 7 chapters begin by covering the basics of HTML, work through an introduction to server controls, validation controls, and navigation controls, explain ASP.NET state, and introduce ASP.NET 2.0 master pages and themes. While the concepts covered in this section are fairly basic with regard to ASP.NET development, even seasoned ASP.NET developers will have something to gain by scanning the right-hand pages because of the new features introduced in Visual Studio 2005.

Section 3 ("ASP.NET database programming") deals with all aspects of coding for data acess using ASP.NET. The first two chapters cover ADO.NET basics, including a tutorial of relational database concepts ("An introduction to relational databases"), examples of how to write database queries (including join, add, insert, and delete queries), an explanation of the ADO.NET disconnected data schema ("Concurrency and the disconnected data architecture"), and a walkthrough of the common ADO.NET classes (SqlConnection, SqlCommand, SqlParameter, SqlDataReader, and SqlDataAdapter are all covered). The next two chapters discuss binding the GridView, DetailsView, and FormView controls to data sources in detail, using the sample application as an illustration and covering concepts such as paging and adding / editing / deleting records. The last chapter introduces the use of object data sources to bind Web controls to data sources through custom business logic classes, which is a powerful feature new to Visual Studio 2005.

 

Walkthrough: Sections 4-5

The second half of the book is dedicated to professional application development with ASP.NET. "Section 4 - Professional ASP.NET skills" is a torrent of information covering user authentication and security, profiles and personalization, Web parts, and application deployment. The focus in this section is on the built-in features new to ASP.NET 2.0, specifically the authentication and personalization classes and controls added to facilitate user management. The sections about SSL, e-mail, and deployment include walkthroughs for configuring the Web server, which is a nice touch given the potential complexities inherent to Web site administration. Also covered in this section are the MultiView and Wizard controls, custom error pages, and several pages devoted to a discussion about how to handle browser back button issues in a state-oriented site.

Throughout the book I found myself thinking "What they should really cover is..." and invariably whatever topic I had come up with was discussed in the next chapter. What really impressed me, however, is the last section (called "Developing reusable code"), which covers the design and development of user controls, custom server controls (rendered controls, superclassed controls, composite controls, and Web controls libraries), and Web service development. These are important advanced concepts to cover, and their inclusion in the book rounds it out quite nicely.

 

Book Excerpt

The following excerpt is from Chapter Two of the book, dealing with validation controls:

"The easiest way to add a validation control to a web form is to drag it from the Toolbox. In this example, four validators have been added to the form: two required field validators and two range validators. In this case, the controls have been added below the table so ASP.NET will use flow layout to position the controls. However, these controls could have been added to a third column of the table. Although these controls aren’t displayed when the form is displayed, the messages in their ErrorMessage properties are displayed if errors are detected.

In this case, the first required field validator checks to make sure that a value has been added to the text box for the interest rate, and the first range validator checks to make sure that this value ranges from 1 to 20. Similarly, the second required field validator checks to make sure that a value has been entered in the text box for years, and the second range validator checks to make sure that this value ranges from 1 to 45.

Validation tests are typically done on the client before the page is posted to the server. That way, a round trip to the server isn’t required to display error messages if any invalid data is detected. In most cases, client-side validation is done when the focus leaves an input control that has validators associated with it. That can happen when the user presses the Tab key to move to the next control or clicks another control to move the focus to that control. Validation is also done when the user clicks on a button that has its CausesValidation property set to True.

To perform client-side validation, a browser must support Dynamic HTML, or DHTML. Because most browsers in use today support DHTML, validation can usually be done on the client. However, validation is always done on the server too when a page is submitted. ASP.NET does this validation after it initializes the page.

When ASP.NET performs the validation tests on the server, it sets the IsValid property of each validator to indicate if the test was successful. In addition, after all the validators are tested, it sets the IsValid property of the page to indicate if all the input data is valid. You can test this property in the event handler for the event that causes the page to be posted to the server. You’ll see how this works when you review the code-behind file for this form."