My Cart (0)

Customer Service 1-800-221-5528

Murach’s ASP.NET 4.5 Web Programming with C# 2012

by Mary Delamater and Anne Boehm
24 chapters, 822 pages, 358 illustrations
Published August 2013
ISBN 978-1-890774-75-2
eBook: $52.50

If you know how to create Windows applications using C#, you’re ready for our classic web programming book. It will get you off to a fast start whether or not you have done any web programming. It will teach you the skills you need to develop bullet-proof web applications on the job. And when you’re done, this book does double duty as the best on-the-job reference that money can buy. There is a 2015 edition of this book.

College Instructors

Go to our instructor’s site to learn more about this book and its instructor’s materials.

 

Simply put, Murach’s ASP.NET 4.5 is a great book. The author does a fantastic job of walking readers through the fundamentals, making the process feel like you’re sitting down with a skilled instructor who’s moving you from one example to the next."

Muhammad Riaz, Baton Rouge Oracle User Group

  • About this Book
  • Table of Contents
  • FREE Downloads
  • Book FAQs
  • Corrections
  • Reviews

What this book does

Section 1: Get started fast

To get you off to a fast start, this 5-chapter section shows you how to use Visual Studio to design, code, and test multi-page web applications that get database data and manage session state. Along the way, you’ll see where HTML5 and CSS3 fit in, so you can tweak that code as needed. This is the essence of ASP.NET Web Forms programming, and this prepares you for rapid progress in the sections that follow.

Section 2: Master the features you’ll use every day

This section teaches you how to use the rest of the server and validation controls…more about state management…how to build and format pages using master pages and themes…how to make a site easy for users to navigate…and how to use friendly URLs that improve search engine results. These are the features that you’ll use all the time.

Section 3: Handle database processing like a pro

In this section, you’ll learn how to use SQL data sources and five ASP.NET controls…GridView, DetailsView, FormView, ListView, and DataPager…to develop professional database applications with little or no C# code. Then, you’ll learn how to use object data sources to create 3-layer applications that let you separate the presentation code from the data access code.

Section 4: Complete your professional skill set

In this section, you’ll learn skills for polishing up your ASP.NET applications. Like: how to secure an application and authenticate users…how to handle back-button refreshes…how to send email…and how to deploy a web application on a remote web server.

Section 5: Go to the next level

This section shows you how to use ASP.NET Ajax to develop rich Internet applications and how to create and consume WCF and Web API services. This section also introduces you to ASP.NET MVC…a completely different approach to web programming than Web Forms…so you can decide if you want to learn more about it.

Who this book is for

If you have a core set of C# programming skills...the kind you get from a book like Murach’s C# 2012...you’re ready for this book. In fact, we’re confident that it will teach you ASP.NET faster and better than any competing book. That’s true whether you’re new to web programming or whether you’re coming to it with a background in another server-side language.

What’s new in this edition

Although ASP.NET and C# haven’t changed significantly in this release, we have added new content to this .NET 4.5 edition:

  • Since HTML5 and CSS3 are now an integral part of ASP.NET applications, we’ve moved the chapter on HTML/CSS from chapter 5 to chapter 3. We’ve also updated all the applications in the book so they use HTML5.
  • We’ve added friendly URLs to the chapter on site navigation, so you can use them to improve the search engine results for your sites.
  • We’ve added material on Web API services to the WCF services chapter, since it’s another popular way to provide services that other websites can use.
  • We’ve added an introductory chapter on ASP.NET MVC, which is an alternative to ASP.NET Web Forms that Microsoft has been promoting, so you can decide whether you want to learn more about it.

Of course, we’ve also updated the material and improved the instruction throughout the book. But that’s something we always do when we publish a new edition of a book.

What software you need

Option 1: Any of the full editions of Visual Studio 2012

To develop ASP.NET applications, you can use any of the full editions of Visual Studio 2012. These editions come with everything you need, including Visual Studio, C# 2012, a built-in web server called IIS Express that’s ideal for testing ASP.NET applications on your own computer, and a scaled-back version of SQL Server called SQL Server Express LocalDB.

Option 2: Visual Studio Express 2012 for Web

For a no-cost alternative to the commercial packages, you can download Visual Studio Express 2012 for Web from Microsoft’s website. It too provides all of the items listed above, it’s a terrific product for learning how to develop ASP.NET applications, and both the applications and the skills that you develop with it will work with any of the full editions of Visual Studio.

The perfect companion book

Murach’s C# 2012 is the perfect companion to our ASP.NET 4.5 book. It presents the C# programming skills that you need for developing ASP.NET web applications. It works for beginners as well as professionals. It lets you learn new skills whenever you need them. And it’s the best on-the-job reference that money can buy.

What people say about this book

"Simply put, Murach’s ASP.NET 4.5 is a great book. The author does a fantastic job of walking readers through the fundamentals, making the process feel like you’re sitting down with a skilled instructor who’s moving you from one example to the next."
-- Muhammad Riaz, Baton Rouge Oracle User Group

"Another awesome book from Murach. I have always been a fan of Murach’s books; I learn so much more from them than any other tech books out there. The format makes learning new materials easier, and their code examples WORK."
-- Posted at an online bookseller

"Great book. Probably the best there is on learning ASP.NET 4.5 C#. Seriously. I’m hard to please, and as a programmer and engineer, I was surprised by how informative this book was."
-- Posted at an online bookseller

"To move forward and create a web application that can do real work beyond page turning, such as storing data in a database, validating input data, and sending email, requires not only HTML, but also JavaScript, light database design, Transact-SQL scripting, and more complex deployment strategies. It also requires the developer to understand the architecture of a web application as compared to the architecture of a web site. Murach’s ASP.NET 4.5 Web Programming with C# 2012 provides the learner and the more experienced programmer with all that and more."
--Eric Notheisen, Enterprise Developers Guild

View the table of contents for this book in a PDF: Table of Contents (PDF)

Click on any chapter title to display or hide its content.

Section 1 The essence of ASP.NET programming

Chapter 1 An introduction to ASP.NET programming

An introduction to web applications

Two pages of a Shopping Cart application

The components of a web application

How static web pages are processed

How dynamic web pages are processed

An introduction to ASP.NET development

Five ways to develop ASP.NET applications

Three environments for developing ASP.NET applications

The components of the .NET Framework

How state is handled in ASP.NET applications

How an ASP.NET application works

The user interface for the Future Value application

The files used by the Future Value application

The aspx code for the Default form

The C# code for the Default form

Chapter 2 How to develop a one-page web application

How to work with ASP.NET web sites

How to start a new web site

How to add a web form to a web site

How to work with the Visual Studio IDE

How to add folders and files to a web site

How to open or close an IIS Express web site

How to convert a file-system web site to IIS Express

How to use Visual Studio to build a web form

How to enter the HTML for a web form

How to add a table to a form

How to add web server controls to a form

How to set the properties of the controls

Common properties for web server controls

How to add validation controls to a form

An introduction to the validation controls

How to use the required field validator

How to use the range validator

How to work with unobtrusive validation

The aspx code for the Future Value form

How to add C# code to a form

How to use the Code Editor

How to use page and control events

The C# code for the Future Value form

How to test a web application

How to run an IIS Express web site

How to view the HTML that’s sent to the browser

Chapter 3 How to use HTML5 and CSS3 with ASP.NET applications

The Future Value application with CSS formatting

The user interface

The HTML that’s generated for a new form

The aspx code for the application

The CSS style sheet for the application

The HTML and CSS skills that you need

How to code HTML elements

How to use the HTML5 semantic elements

How to use the div and span elements with HTML5

How to provide CSS styles for an HTML page

How to code the basic CSS selectors

How to code CSS rule sets and comments

How to ensure cross-browser compatibility

Visual Studio features for working with HTML

How to use the features for entering HTML

How to add the attributes for the WAI-ARIA accessibility standards

Visual Studio features for working with CSS

How to create and edit an external style sheet

How to use Visual Studio to create and modify styles

How to use the Apply Styles window

How to use the CSS Properties window

How to use the Manage Styles window

Chapter 4 How to develop a multi-page web application

Introduction to the Shopping Cart application

The two pages the Shopping Cart application

The files and folders used by the Shopping Cart application

How to work with multi-page web sites

How to create a web site that has starting folders and files

How to change the starting page for a web site

How to rename or delete folders and files

How to add a class to a web site

How to redirect or transfer to another page

How to use cross-page posting

How to code absolute and relative URLs

How to create and use data sources

How to create an SQL data source

How to configure an SQL data source

How to bind a drop-down list to a data source

How to use C# code to get data from a data source

How to use session state

How session state works

How to work with data in session state

The business classes of the Shopping Cart application

The members of the three business classes

The code for the Product class

The code for the CartItem class

The code for the CartItemList class

The web forms of the Shopping Cart application

The aspx code for the Order page

The C# code for the Order page

The aspx code for the Cart page

The C# code for the Cart page

Chapter 5 How to test and debug ASP.NET applications

How to test an ASP.NET web site

How to test a web site

How to test a web site in two or more browsers at the same time

How to use the Exception Assistant

How to use the Page Inspector

How to use the debugger

How to use breakpoints

How to use tracepoints

How to work in break mode

How to use the debugging windows to monitor variables

How to use the trace feature

How to enable the trace feature

How to interpret trace output

How to create custom trace messages

Section 2 ASP.NET essentials

Chapter 6 How to use the standard server controls

An introduction to the standard server controls

The server controls you’ll use the most

How to use C# to work with the data in server controls

How to set the focus, default button, tab order, and access keys for a form

How to use the common server controls

How to use labels and text boxes

How to use check boxes and radio buttons

How to use image and hyperlink controls

How to use the file upload control

How to use the button controls

How to use buttons, link buttons, and image buttons

How to use the Command event

How to use the list controls

How to create drop-down lists and list boxes

How to use the properties for working with list controls

How to use the members for list item collections

How to use check box lists and radio button lists

How to use bulleted lists

A CheckOut page that uses server controls

The user interface and link elements

The aspx code

The code-behind file for the CheckOut page

An introduction to the other standard server controls

When and how to use the other standard server controls

How to use the Wizard control

Chapter 7 How to use the validation controls

Introduction to the validation controls

How ASP.NET processes the validation controls

How to set the attributes of the validators

How to provide for unobtrusive validation

How to use the validators

How to use the required field validator

How to use the compare validator

How to use the range validator

How to use the regular expression validator

How to create regular expressions

How to use a custom validator

Validation techniques

How to use the validation summary control

How to use validation groups

A CheckOut page that uses validation controls

The user interface

The aspx code

The C# code

Chapter 8 How to work with state, cookies, and URL encoding

How to use view state

How to work with view state

How to use view state for your own data

How to use session state

How to work with session state

When to save and retrieve session state items

Options for storing session state data and tracking session IDs

How to use application state and caching

How application state and caching work

How to work with application state and cache data

How to work with application events

How to use cookies and URL encoding

How to create cookies

How to work with cookies

How to enable or disable cookies

How to use URL encoding

An application that uses cookies, application state, and caching

The Order and CheckOut pages

The critical C# code for the Order and CheckOut pages

Chapter 9 How to use master pages

How to create master pages

An introduction to master pages

How to create a master page

How to work with the ClientIDMode property

How to create and develop content pages

How to create a content page

How to add content to a page

How to customize content pages

How to add default content to a master page

How to override and accept the default content from a content page

How to expose a public property in a master page

How to access a public property from a content page

The Shopping Cart application

Two pages of the Shopping Cart application

The aspx code for the master page

The code-behind file for the master page

The aspx code for the Order page

The aspx code for the Cart page

The Load event handler in the code-behind file for the Cart page

Chapter 10 How to use themes

An introduction to themes

A page with two different themes applied

How themes work

The difference between customization and style sheet themes

How to work with themes and skins

How to create and use themes and skins

The skln and CSS files for the Bats theme

How to apply themes and skins

How to remove themes

Chapter 11 How to use site navigation and ASP.NET routing

How to use the navigation controls

An introduction to the navigation controls

How to create a web.sitemap file

How to create a SiteMapDataSource control

How to use the Menu control

How to use the TreeView control

How to use the SiteMapPath control

The aspx code for the master page of the Shopping Cart application

How to use ASP.NET routing

An introduction to ASP.NET routing and friendly URLs

How to create a route collection

How to work with route parameters

How to work with file paths

The C# code for the Order page with a dynamic route

How to use the navigation controls with ASP.NET routing

The global.asax file for the Shopping Cart application with friendly URLs

The web.sitemap file with traditional URLs

The web.sitemap file with friendly URLs

Section 3 ASP.NET database programming

Chapter 12 An introduction to database programming

An introduction to relational databases

How a table is organized

How the tables in a database are related

How the columns in a table are defined

The design of the Halloween database

How to use SQL to work with the data in a relational database

How to query a single table

How to join data from two or more tables

How to add, update, and delete data in a table

How to work with other database objects

How to work with views

How to work with stored procedures

An introduction to ADO.NET 4.5

How the basic ADO.NET components work

Concurrency and the disconnected data architecture

How to work with data without using a data adapter

Chapter 13 How to use SQL data sources

How to create a SQL data source

How the SqlDataSource control works

How to choose a data source type

How to choose a data connection

How to create a connection

How to save the connection string in the web.config file

How to configure the Select statement

How to create a Where clause

How select parameters work

How to use custom statements and stored procedures

How to enter custom statements

How to select stored procedures

How to create a Select statement with the Query Builder

How to define the parameters

How to use the DataList control

How the DataList control works

How to define the templates for a data list

How to format a data list

How to use data binding

How to bind a list control to a data source

How to bind the controls in a template

A Product List application

The user interface

The aspx file

How to use the advanced features of a SQL data source

How to create a data source that can update the database

How to change the data source mode

How to use caching

Chapter 14 How to use the GridView control

How to customize the GridView control

How the GridView control works

How to define the fields in a GridView control

Elements used to create and format fields

How to enable sorting

How to enable paging

How to customize paging

A list application that uses a GridView control

The Product List application

The aspx file

How to update GridView data

How to work with command fields

How to use events raised by the GridView control

How to insert a row in a GridView control

A maintenance application that uses a GridView control

The Category Maintenance application

The aspx file

The code-behind file

How to work with template fields

How to create template fields

The template version of the Category Maintenance application

The aspx code for the template version

Chapter 15 How to use the DetailsView and FormView controls

How to use the DetailsView control

An introduction to the DetailsView control

Attributes and child elements for the DetailsView control

How to define the fields in a DetailsView control

How to enable paging

How to create a Master/Detail page

How to update the data in a DetailsView control

An introduction to command buttons

How to add command buttons

How to use events raised by the DetailsView control

How to create template fields

The Product Maintenance application

The operation of the application

The aspx file

The code-behind file

How to use the FormView control

An introduction to the FormView control

How to work with the Item template

How to work with the EditItem and InsertItem templates

A Shopping Cart application that uses a FormView control

The operation of the application

The aspx file for the Order page

The code-behind file for the Order page

Chapter 16 How to use the ListView and DataPager controls

How to use the ListView control

An introduction to the ListView control

How to configure a ListView control

How to work with the Layout template

How to work with the Item template

How to provide for sorting

How to provide for paging

How to customize paging

How to group ListView data

A list application that uses a ListView control

The Product List application

The aspx file

How to update ListView data

How to use buttons to perform update operations

How to work with the EditItem and InsertItem templates

How to use events raised by the ListView control

Chapter 17 How to use object data sources with ADO.NET

An introduction to object data sources

How 3-layer applications work in ASP.NET

How to create and work with ADO.NET classes

How to use the ObjectDataSource control

How to configure an ObjectDataSource control

How to work with bound controls

A Product List application

The aspx file

The ProductDB class

How to create a data access class

How to design a data access class

How to create a select method

How to create update, delete, and insert methods

How to use attributes to mark a data access class

A Category Maintenance application

The design

The aspx file

The code-behind file

The Category class

The CategoryDB class

How to use paging and sorting with object data sources

How to configure an ObjectDataSource control for paging and sorting

The aspx file that provides for paging and sorting

The code-behind file that provides for sorting

How to create a data access class that provides for paging and sorting

Section 4 Finishing an ASP.NET application

Chapter 18 How to secure a web site

An introduction to SSL

How secure connections work

How to enable SSL for a project that uses IIS Express

How digital secure certificates work

How to use a secure connection

How to request a secure connection

How to force a page to use a secure connection

A Halloween Store application that uses SSL

The operation of the Halloween Store application

The code for the Halloween Store application

Chapter 19 How to authenticate and authorize users

An introduction to authentication

Three types of authentication

How forms-based authentication works

How to set up authentication and authorization

How to use SQL Server Express LocalDB with the Web Site Administration Tool

How to start the Web Site Administration Tool

How to enable forms-based authentication

How to create and manage roles

How to create and manage users

How to create and manage access rules

How to use the login controls

How to use the Login control

How to use the LoginStatus and LoginName controls

How to use the CreateUserWizard control

How to use the PasswordRecovery control

How to use the ChangePassword control

How to use the LoginView control

The Authentication application

The pages

The directory structure

The access rules

The web.config files

Chapter 20 How to use email, custom error pages, and back-button control

How to send email

An introduction to email

How to use a third-party SMTP server

How to create an email message

How to send an email message

How to add an attachment to an email message

How to create an HTML message

How to create an HTML message with an embedded image

How to use custom error handling

An introduction to custom error handling

How to get and use the Exception object for an error

How to create a custom class for handling exceptions

How to handle HTTP errors with the web.config file

How to handle the back-button problem

An introduction to the back-button problem

How to use the Post-Redirect-Get pattern

How to use timestamps

Chapter 21 How to configure and deploy ASP.NET applications

How to use the Web Site Administration Tool

How to use the Security tab

How to use the Application tab

How to use the Provider tab

An introduction to deployment

Three ways to deploy an ASP.NET application

How to use XCopy deployment

How to use one-click deployment

How to create a publish profile

How to define the connection

How to set the file and database options

How to preview the files to be deployed

How to publish the web site

How to create and use a Setup program

How to create a setup project using InstallShield

How to configure an InstallShield project for deployment to IIS

How to add output files to an InstallShield project

How to create and use the installation files for a Setup program

Section 5 Going to the next level

Chapter 22 How to use ASP.NET Ajax

An introduction to Ajax

Examples of Ajax applications

How Ajax works

An introduction to ASP.NET Ajax

How ASP.NET Ajax works

The ASP.NET Ajax server controls

The ASP.NET Ajax Control Toolkit

How to use the ASP.NET Ajax server controls

How to use the ScriptManager control

How to use the ScriptManagerProxy control

How to use the UpdatePanel control

How to use the Timer control

How to use the UpdateProgress control

An application that uses ASP.NET Ajax

The View Products page

The ProductView class

The ProductViewList class

The aspx file and the first UpdatePanel control

The second UpdatePanel control

The code-behind file

Chapter 23 How to create and use WCF and Web API services

An introduction to web services

SOAP services

REST services

How to create a WCF service

How to start a WCF service application

How to code a service contract interface and a data contract class

How to code a service contract class that implements the interface

How to view and test a WCF service

How to create a web site that consumes a WCF service

The Edit Categories page of the WCF client web site

How to add a WCF service reference to a client web site

How to consume a WCF service

How to create a Web API service

How to start a Web API service

How to write a web service controller

How to view and test a Web API service

How to create a web site that consumes a Web API service

The Edit Categories page of the Web API client web site

How to consume a Web API service using jQuery

How to consume a Web API service using C# code

Chapter 24 An introduction to ASP.NET MVC

An introduction to MVC

The MVC design pattern

The Shopping Cart as an MVC application

An introduction to ASP.NET MVC

How to start an ASP.NET MVC application

The folders and files for a new MVC application

The Razor view engine and syntax

How to work with routing

How to create a model

How to create a controller

How to create a view

How to work with views

How to work with regular views

How to work with strongly-typed views

How to work with controls and postbacks

How to work with controls

How to work with redirection

How to add AutoPostBack functionality with jQuery

How to work with the FormCollection object

How to work with model binding

Appendixes

Appendix A How to install and use the software and downloadable files

How to download and install the files for this book

How to install Visual Studio 2012

How to use the Halloween database

How to set up IIS on your local computer

Sample Chapters

Chapter 1: An introduction to ASP.NET web programming

This chapter gives you the background you need to start writing ASP.NET 4.5 web applications of your own. So you’ll find out how web applications work, what software you need to develop them, and how the code that represents the design of a web form is coordinated with the C# code that makes the web form work the way you want it to.

Chapter 2: How to develop a one-page web application

This chapter teaches you how to use Visual Studio 2012 to design, code, and test a one-page web application. That means you’ll see how to build a web form using web server controls and HTML server controls, how to check for acceptable user input using validation controls, and how to write the C# code for the web form’s code-behind file.

Chapter 1 PDF (1.8Mb) Download Now

Chapter 2 PDF (1.4Mb) Download Now

Book applications and exercises

This download includes:

  • The source code for the applications that are presented in the book
  • The database that’s used by the book applications
  • The starting source code and data for the exercises in the book
  • The solutions to the book exercises so you can check your work

The appendix in the book describes how to install and use these files.

Exe file for Windows (64.4Mb) Download Now

Zip file for any system (64.4Mb) Download Now

Below are the answers to the questions that have come up most often about this book. If you have any questions that aren’t answered here, please email us. Thanks!

How Visual Studio 2013 affects this book

Visual Studio 2013 has a few nasty but relatively minor effects on what is taught in our ASP.NET 4.5 books. For this reason, we recommend that you use VS 2012 while you’re learning from our book.

If you do upgrade to VS 2013, though, here are the changes that you need to deal with.

No more websites

One of the new directions of VS 2013 is the concept of “One ASP.NET.” That means that Microsoft wants the creation of all ASP.NET project types to work similarly. As a result, VS 2013 provides only one option when you create a new application: ASP.Net Web Application. Then, within that option, you can select a Web Forms, MVC, Web API, Single Page Application (SPA), or Facebook project.

This eliminates the choice between starting a website or a web application, and it changes the way you start a new web application. It also changes the way ASP.NET special folders are used. In particular, there isn’t an App_Code folder and the code in a web application doesn’t need to go into it.

This will also change the way an application is deployed because a web application needs to be compiled before it is deployed.

No development server

With VS 2013, there is no development server for testing applications. As a result, you will always use IIS Express instead of the development server. Although this won’t change the way you create new web applications, this will change the way you open and use the downloadable applications and exercises for this book.

The Membership system is being replaced by the Identity system

Because Microsoft gets a lot of criticism about their frameworks being bloated and plodding, Microsoft is trying to be more modular. For instance, the Entity Framework is already a Nuget package.

Similarly, the Membership system of VS 2012 is being replaced by an Identity system in VS 2013 that will also be a Nuget package. If you’re interested in the reasons behind the replacement, here’s a link to a good description: http://www.asp.net/identity/overview/getting-started/introduction-to-aspnet-identity

The trouble is that the documentation for the Identity system is very thin right now, and this feature doesn’t seem ready for prime time. We base this opinion in part on the articles at these links:
http://www.asp.net/aspnet/overview/authentication-and-identity
http://blogs.msdn.com/b/webdev/archive/2013/06/27/introducing-asp-net-identity-membership-system-for-asp-net-applications.aspx

The Website Administration Tool is gone

As part of this new modular direction, the Website Administration Tool has been removed from VS 2013. This is partly because of the new Identity architecture, but also because the Website Administration Tool uses the development server, and Microsoft hasn’t updated it to work with IIS Express.
If you want to use the Website Administration Tool with VS 2013, however, there is a command prompt option for running this Tool in IIS Express. For more information, you can go to this link:
http://blogs.msdn.com/b/webdev/archive/2013/08/19/asp-net-web-configuration-tool-missing-in-visual-studio-2013.aspx
Then, you can use the Membership system too.

Our recommendation: Don’t upgrade to VS 2013 right now

With this as background, you can see why we recommend that you don’t upgrade to VS 2013 until you’re through with our book. That way everything will work just as it is described in the book.
After you finish learning ASP.NET 4.5 with VS 2012 from our book, you can upgrade to VS 2013 whenever you want to...after it’s clear that all of the features of VS 2013 are ready to go. Then, because you’ve already read our book, you will have all the skills and concepts that you need for making that upgrade with relative ease.

To view the corrections for this book in a PDF, just click on this link: View the corrections

Then, if you find any other errors, please email us so we can correct them in the next printing of the book. Thank you!

There are no reviews for this product yet.

To leave a review, please log in to your account.     Log In Here

Our Ironclad Guarantee

You must be satisfied. Try our print books for 30 days or our eBooks for 14 days. If they aren't the best you've ever used, you can return the books or cancel the eBooks for a prompt refund. No questions asked!

Contact Murach Books

For orders and customer service:

1-800-221-5528

Weekdays, 8 to 4 Pacific Time

College Instructors

If you're a college instructor who would like to consider a book for a course, please visit our website for instructors to learn how to get a complimentary review copy and the full set of instructional materials.