O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Sams Teach Yourself ASP.NET 3.5 in 24 Hours, Complete Starter Kit

Book Description

Sams Teach Yourself ASP.NET 3.5 in 24 Hours

Scott Mitchell

Starter Kit

DVD includes Microsoft Visual Web Developer 2008 Express Edition

In just 24 sessions of one hour or less, you will be up and running with ASP.NET 3.5. Using a straightforward, step-by-step approach, each lesson builds upon a real-world foundation forged in both technology and business matters, allowing you to learn the essentials of building dynamic, data-driven web applications from the ground up.

Step-by-step instructions carefully walk you through the most common questions, issues, and tasks.

Q&As, quizzes, and exercises at the end of each lesson help you build and test your knowledge.

By the Way, Did You Know?, and Watch Out! boxes point out shortcuts and solutions.

Learn how to…

  • Design and create ASP.NET web pages

  • Use Microsoft Visual Web Developer to quickly and professionally build ASP.NET websites

  • Collect input from users visiting your web pages

  • Display database data through a web page

  • Edit, insert, delete, sort, and page through database data from an ASP.NET page

  • Build a website that supports user accounts

  • Use Ajax to design interactive web user interfaces

  • As editor and main contributor to 4GuysFromRolla.com, a popular ASP.NET resource website, Scott Mitchell has authored more than a thousand articles on Microsoft web technologies since 1998. In addition to his vast collection of online articles, Scott has written six previous books on ASP and ASP.NET: Sams Teach Yourself Active Server Pages 3.0 in 21 Days (Sams); Designing Active Server Pages (O’Reilly); ASP.NET: Tips, Tutorials, and Code (Sams); ASP.NET Data Web Controls Kick Start (Sams); Sams Teach Yourself ASP.NET in 24 Hours (Sams); and Sams Teach Yourself ASP.NET 2.0 in 24 Hours (Sams). Scott has also written a number of magazine articles and is a regular columnist for Microsoft’s MSDN Magazine.

    DVD Includes:

  • Microsoft Visual Web Developer 2008 Express Edition

  • On the Web:

  • Register your book at informit.com/title/9780672329975 for access to author code, examples, updates and corrections as they become available.

  • Category: Microsoft Programming/ASP.NET

    Covers: ASP.NET 3.5

    User Level: Beginning—Intermediate

    Table of Contents

    1. Copyright
      1. Dedication
    2. About the Author
    3. Acknowledgments
    4. We Want to Hear from You!
      1. Reader Services
    5. Introduction
      1. Audience and Organization
      2. Conventions Used in This Book
    6. I. Overview of ASP.NET 3.5
      1. 1. Getting Started with ASP.NET 3.5
        1. What Is ASP.NET?
          1. Serving Static Web Pages
          2. Serving Dynamic Web Pages
          3. Hosting ASP.NET Web Pages
            1. Develop Locally, Deploy to a Web Host
        2. Installing the ASP.NET Engine, Editor, and Database System
        3. A Brief Tour of Visual Web Developer
          1. Creating a New ASP.NET Website
          2. Creating and Testing a Simple ASP.NET Web Page
        4. Summary
        5. Q&A
        6. Workshop
          1. Quiz
          2. Answers
          3. Exercises
      2. 2. Understanding the ASP.NET Programming Model
        1. Examining the HTML Portion of an ASP.NET Web Page
          1. A Brief HTML Primer
            1. Extraneous Whitespace
            2. Nested Tags
          2. Creating the HTML Portion of an ASP.NET Web Page Using Visual Web Developer
            1. Editing the HTML Content Using the Designer
            2. Examining the HTML Content
        2. Examining the Source Code Portion of an ASP.NET Web Page
          1. A Quick Object-Oriented Programming Primer
            1. Examining Event-Driven Programming
            2. Out-of-Order Execution
          2. Event Handlers in ASP.NET
          3. Programmatically Working with Web Controls
        3. Summary
        4. Q&A
        5. Workshop
          1. Quiz
          2. Answers
          3. Exercises
      3. 3. Using Visual Web Developer
        1. Creating a New Website
          1. Choosing a Website Template
          2. Specifying the Website’s Location
          3. Choosing the Source Code Programming Language
        2. Opening Existing Websites
        3. Working with Web Pages and Other Content
          1. Adding Content to Your Website
            1. Adding Existing Content
          2. Moving, Renaming, and Deleting Content
        4. Customizing the Visual Web Developer Experience
        5. Viewing, Moving, and Resizing Windows
        6. A World of Help at Your Fingertips
        7. Summary
        8. Q&A
        9. Workshop
          1. Quiz
          2. Answers
          3. Exercise
      4. 4. Designing, Creating, and Testing ASP.NET Web Pages
        1. Specifying the Design Requirements
          1. Formulating the Features for Our Financial Calculator
          2. Deciding on the User Interface
        2. Creating the User Interface
          1. Adding the Three TextBox Web Controls
          2. Adding the Compute Monthly Cost Button
          3. Creating a Label Web Control for the Output
        3. Writing the Source Code for the ASP.NET Web Page
          1. Reading the Values in the TextBox Web Controls
          2. The Complete Source Code
        4. Testing the Financial Calculator
          1. Viewing the Rendered Source Code
          2. Testing Erroneous Input
        5. Examining the Source Code
        6. Using the Debugger
        7. Summary
        8. Q&A
        9. Workshop
          1. Quiz
          2. Answers
          3. Exercises
      5. 5. Understanding Visual Basic’s Variables and Operators
        1. The Purpose of Programming Languages
          1. Concepts Common to All Programming Languages
        2. Declaring and Using Variables
          1. Assigning Values to Variables
          2. Declaring a Variable
          3. Rules for Naming Variables
          4. Examining Variable Data Types
            1. Integer Types
            2. Nonintegral Numeric Types
            3. Boolean Data Types
            4. String Types
            5. Date Types
            6. The Object Type
          5. Examining the Dim Statement
            1. Performing Assignment When Declaring a Variable
        3. Examining Visual Basic’s Operators
          1. Arithmetic Operators
          2. Exploring the Comparison Operators
          3. Understanding the Concatenation Operator
          4. Visual Basic’s Assignment Operators
            1. Shorthand Versions for Common Assignments
        4. Learning Visual Basic’s Type Rules
          1. Understanding Casting
            1. Widening and Narrowing Casts
            2. Rules for Implicit Casting
        5. Summary
        6. Q&A
        7. Workshop
          1. Quiz
          2. Answers
          3. Exercises
      6. 6. Managing Program Flow with Visual Basic’s Control Structures
        1. Understanding Control Structures
        2. Exploring the Conditional Control Structure
          1. Executing Instructions If the Conditional Is False
          2. Performing Another If Statement When the Condition Is False
        3. Working with Visual Basic’s Looping Control Structures
          1. Using For ... Next Loops
          2. Do ... Loop Loops
        4. Exploring the Modularizing Control Structures: Subroutines and Functions
          1. Reducing Code Redundancy Using Subroutines and Functions
          2. Passing in Parameters to a Subroutine or Function
          3. Returning Values with Functions
          4. Where Do Event Handlers Fit In?
        5. Summary
        6. Q&A
        7. Workshop
          1. Quiz
          2. Answers
          3. Exercises
      7. 7. Working with Objects in Visual Basic
        1. Reexamining the Role of Classes and Objects
          1. The Role of Objects in an ASP.NET Web Application
            1. The Four Common Tasks Performed with Objects
        2. Creating an Object
          1. Constructors with Parameters
        3. Setting an Object’s Properties
        4. Calling an Object’s Methods
        5. Creating Event Handlers for an Object’s Events
        6. Summary
        7. Q&A
        8. Workshop
          1. Quiz
          2. Answers
          3. Exercises
      8. 8. ASP.NET Web Controls for Displaying Text
        1. Examining the Web Controls Designed for Displaying Text
        2. Using the Literal Web Control
          1. Setting the Literal Control’s Text Property Programmatically
        3. Using the Label Web Control
          1. Examining the Formatting Properties of the Label Web Control
            1. Looking at the Color Properties
            2. Examining the Border Properties
            3. Delving into the Font Properties
            4. The Miscellaneous Properties
        4. Summary
        5. Q&A
        6. Workshop
          1. Quiz
          2. Answers
          3. Exercises
    7. II. Collecting and Processing User Input
      1. 9. Web Form Basics
        1. Gathering User Input in an HTML Web Page
          1. Examining the <input> HTML Element
          2. Passing the Input Back to the Web Server Using the <form> Element
            1. Comparing Postback Forms and Redirect Forms
        2. Dissecting ASP.NET Web Forms
          1. Adding Web Controls to Collect User Input
          2. Testing the BMICalculator.aspx ASP.NET Page
          3. Web Forms Remember the Values the Users Enter
          4. Writing the Code for BMICalculator.aspx
        3. Summary
        4. Q&A
        5. Workshop
          1. Quiz
          2. Answers
          3. Exercises
      2. 10. Using Text Boxes to Collect Input
        1. Learning About the TextBox Web Control Basics
          1. Performing an Action When the User Submits the Form
        2. Creating Multiline and Password Text Boxes
          1. Using Multiline Text Boxes
          2. Using Password Text Boxes
            1. Password Text Box Values Are Not Continued Across Postbacks
        3. Examining the TextBox Web Control’s Properties
          1. Specifying the Length of a Text Box
          2. Limiting the Number of Characters a User Can Enter into a Text Box
          3. Aesthetic Properties—Changing the Text Box’s Font and Color
        4. Summary
        5. Q&A
        6. Workshop
          1. Quiz
          2. Answers
          3. Exercises
      3. 11. Collecting Input Using Drop-Down Lists, Radio Buttons, and Check Boxes
        1. Examining the Different Types of User Input Classifications
          1. Using an Appropriate Web Control
        2. Examining the DropDownList Web Control
          1. Adding Options to the DropDownList Web Control
          2. Adding a DropDownList Web Control to an ASP.NET Web Page
          3. The DropDownList Web Control’s Formatting Properties
        3. Selecting One Option from a List of Suitable Choices with RadioButton Web Controls
          1. Using the Text and GroupName Properties
          2. Determining What RadioButton Web Control Was Selected
          3. A Look at the Formatting Properties
        4. Using the CheckBox Web Control
          1. Determining What Check Boxes Have Been Checked
        5. Summary
        6. Q&A
        7. Workshop
          1. Quiz
          2. Answers
          3. Exercises
      4. 12. Validating User Input with Validation Controls
        1. Examining the Need for User Input Validation
          1. Types of Input Validation
            1. Required Field Input Validation
            2. Data Type Validation
            3. Range Input Validation
            4. Comparison Validation
            5. Pattern Validation
        2. Validating User Input in an ASP.NET Web Page
          1. An ASP.NET Web Page for Examining the Validation Controls
        3. Examining the RequiredFieldValidator Validation Control
          1. Specifying What Web Control the Validation Web Control Is Validating
          2. Specifying What Error Message to Display for Invalid Input
          3. Testing the ASP.NET Page
            1. Client-Side and Server-Side Validation
          4. Programmatically Determining Whether the User’s Input Is Valid
          5. Summarizing the Basic Validation Control Features
        4. Examining the CompareValidator
          1. Using the CompareValidator to Compare One Input to Another
        5. Using the RangeValidator
        6. Validating Input with the RegularExpressionValidator
        7. Formatting Properties for the Validation Web Controls
        8. A Look at the Remaining Validation Controls
        9. Summary
        10. Q&A
        11. Workshop
          1. Quiz
          2. Answers
          3. Exercises
    8. III. Working with Databases
      1. 13. An Introduction to Databases
        1. Examining Database Fundamentals
          1. A Look at Current Database Systems
        2. Storing Structured Data
          1. Examining a Table’s Columns
          2. Primary Key Columns
        3. Creating a New Database
        4. Creating Database Tables
          1. A Discussion on Database Design
            1. Uniquely Identifying Each Record
            2. Modeling a System’s Logical Entities as Related Tables
        5. Adding Data to the Books Table
        6. Summary
        7. Q&A
        8. Workshop
          1. Quiz
          2. Answers
          3. Exercises
      2. 14. Accessing Data with the Data Source Web Controls
        1. Examining the Data Source Controls
          1. Working with the SqlDataSource Control
            1. Step 1: Choose Your Data Connection
            2. Step 2: Configure the Select Statement
            3. Step 3: Test the Query
          2. Examining the SqlDataSource Control’s Markup
        2. A Look at SQL, the Language of Databases
        3. Delving into the SQL SELECT Statement
          1. Viewing SQL Queries Results in Visual Web Developer
          2. Restricting Returned Rows Using the WHERE Clause
            1. Understanding What Happens When a WHERE Clause Is Present
          3. Ordering the Results Using the ORDER BY Clause
            1. Sorting in Ascending and Descending Order
        4. Filtering and Sorting Data from the SqlDataSource Control’s Wizard
          1. Filtering the SqlDataSource Control’s Data
          2. Sorting the SqlDataSource Control’s Data
          3. Testing Queries with WHERE Clauses
          4. A Look at the SqlDataSource Control’s Markup
        5. Summary
        6. Q&A
        7. Workshop
          1. Quiz
          2. Answers
          3. Exercises
      3. 15. Displaying Data with the Data Web Controls
        1. An Overview of Data Web Controls
        2. Displaying Data with the GridView Control
          1. A Look at the GridView’s Declarative Markup
          2. Customizing the Appearance of the GridView
            1. Formatting from the Properties Window
            2. Formatting the GridView’s Fields
            3. Formatting with the AutoFormat Dialog Box
        3. Showing One Record at a Time with the DetailsView
          1. Customizing the Paging Interface
          2. Customizing the Appearance of the DetailsView
        4. Paging and Sorting with the GridView
          1. A Look at Paging
            1. Testing the Paging Functionality
          2. Providing Sortable Data
            1. Customizing the Sorting Interface
        5. Summary
        6. Q&A
        7. Workshop
          1. Quiz
          2. Answers
          3. Exercises
      4. 16. Deleting, Inserting, and Editing Data
        1. Updating, Deleting, and Inserting Data with the SqlDataSource
          1. Looking at the SqlDataSource Control’s Declarative Markup
        2. Looking at the Data Modification SQL Statements
          1. Examining the INSERT Statement
          2. Deleting Data with the DELETE Statement
          3. Editing Data with UPDATE
        3. Editing and Deleting Data with the GridView
          1. Allowing Users to Delete Data
            1. Customizing the Delete Field
            2. Looking at the Inner Workings of Deleting
          2. Creating an Editable GridView
          3. Customizing the Editing Interface and Updating Rules
            1. Marking Fields as Read-Only
            2. Editing and Formatted Fields
            3. Using Nulls or Blank Strings
            4. Replacing the Autogenerated TextBox with a Custom Editing Interface
        4. Inserting Data with the DetailsView
          1. Customizing the Insertable DetailsView
        5. Summary
        6. Q&A
        7. Workshop
          1. Quiz
          2. Answers
          3. Exercises
      5. 17. Working with Data-Bound DropDownLists, RadioButtons, and CheckBoxes
        1. An Overview of the List Web Controls
          1. Binding Data to a List Web Control
          2. The Benefits of Dynamically Populating a List Control
          3. Programmatically Responding to a Changed Selection
            1. Automatically Posting Back When a List Web Control Changes
        2. Filtering Results Using the DropDownList
          1. Listing the Genres in a DropDownList
          2. Filtering the Data Based on the Selected Genre
        3. Collecting User Input with CheckBoxLists and RadioButtonLists
          1. Enumerating the List Web Control’s List Items
          2. Using SelectedItem and SelectedValue
          3. Customizing the Appearance of the RadioButtonList and CheckBoxList Controls
        4. Summary
        5. Q&A
        6. Workshop
          1. Quiz
          2. Answers
          3. Exercises
      6. 18. Exploring Data Binding and Other Data-Related Topics
        1. Looking at the GridView’s and DetailsView’s Fields
          1. Looking at How Bit Columns Are Displayed
          2. Displaying Hyperlinks with the HyperLinkField
          3. Displaying Images with the ImageField
        2. Using Wildcards in a WHERE Filter Expression
        3. An Examination of Data Binding
          1. The Difference Between One-Way and Two-Way Data Binding
          2. Specifying the Data Bindings for a Web Control
            1. A Look at the Declarative Markup
        4. Summary
        5. Q&A
        6. Workshop
          1. Quiz
          2. Answers
          3. Exercises
      7. 19. Using Templated Data Web Controls
        1. Displaying Data Using the ListView Control
          1. Examining How the ListView Renders Its LayoutTemplate and ItemTemplate
          2. Adding Templates Using the Configure ListView Option
          3. Adding Templates Manually
        2. Paging and Sorting the ListView’s Data
          1. Creating a Sorting Interface
          2. Adding Paging Support
        3. Displaying One Record at a Time with the FormView Control
          1. Paging Through the Records One at a Time
          2. Examining the FormView’s Available Templates
          3. Customizing the Templates
        4. Summary
        5. Q&A
        6. Workshop
          1. Quiz
          2. Answers
          3. Exercises
    9. IV. Site Navigation, User Management, Page Layout, AJAX, and Deployment
      1. 20. Defining a Site Map and Providing Site Navigation
        1. An Overview of ASP.NET’s Site Navigation Features
        2. Defining the Website’s Structure Using a Site Map
          1. Adding the Site Map
          2. Building the Site Map
        3. Displaying a Breadcrumb with the SiteMapPath Control
          1. Customizing the SiteMapPath’s Appearance
        4. Showing the Entire Site Structure
          1. Displaying the Site’s Structure in a TreeView
            1. Customizing the TreeView’s Appearance
          2. Using Menus to Show the Site’s Structure
            1. Configuring the Menu’s Static and Dynamic Portions
            2. Customizing the Menu’s Appearance
        5. Summary
        6. Q&A
        7. Workshop
          1. Quiz
          2. Answers
          3. Exercises
      2. 21. Managing Your Site’s Users
        1. An Overview of User Accounts in ASP.NET
          1. Configuring an ASP.NET Website to Support Membership
            1. Creating and Managing Users
          2. Classifying Users by Role
          3. Creating and Managing Access Rules
          4. Configuring a Website’s SMTP Settings
        2. Allowing Visitors to Create New User Accounts
          1. Customizing the CreateUserWizard Control
            1. Specifying the Text for the Labels, Text Boxes, and Buttons
            2. Dictating What Information Users Must Provide
          2. Emailing Users a Message After Creating Their Accounts
          3. Creating Inactive User Accounts
        3. Logging In to the Website with the Login Control
          1. Customizing the Login Control
          2. Logging Out
            1. Specifying the Login Page URL
        4. Displaying Content Based on Authentication Status
        5. Summary
        6. Q&A
        7. Workshop
          1. Quiz
          2. Answers
          3. Exercises
      3. 22. Using Master Pages to Provide Sitewide Page Templates
        1. An Overview of Master Pages
        2. Creating a Master Page
          1. Designing the Sitewide Template
            1. Creating the Header Region
            2. Crafting the Navigation Region
            3. Creating the Main Region and Footer Region
        3. Creating a Content Page
          1. Having an Existing Page Inherit from a Master Page
        4. Providing Default Content in a Master Page
          1. Choosing to Use Default or Custom Content in an ASP.NET Page
        5. Working with a Master Page’s Source Code Portion
          1. Testing the Master Page’s Functionality
        6. Summary
        7. Q&A
        8. Workshop
          1. Quiz
          2. Answers
          3. Exercises
      4. 23. Building More Responsive Web Pages with ASP.NET AJAX
        1. An Overview of AJAX
          1. A Look at the Technologies Involved
        2. Using the ASP.NET AJAX Framework
          1. Working with the UpdatePanel Control
          2. Using Multiple UpdatePanel Controls
          3. Displaying a Progress Message for Long-Running Partial Postbacks
        3. Summary
        4. Q&A
        5. Workshop
          1. Quiz
          2. Answers
          3. Exercises
      5. 24. Deploying Your Website
        1. Choosing a Web-Hosting Company
          1. Getting Started with a Web-Hosting Company
        2. Understanding the Deployment Process
          1. Building the Sample Web Application
          2. Uploading the Website’s Files
          3. Replicating Your Database
            1. Using the Database Publishing Wizard
            2. Executing the Output Script on the Web-Hosting Company’s Database Server
          4. Updating the Connection Strings in Web.config
        3. Visiting the Remote Website
        4. Summary
        5. Q&A
        6. Workshop
          1. Quiz
          2. Answers
          3. Exercises