Sams Teach Yourself ASP.NET 2.0 in 24 Hours

Book description

If you are familiar with creating HTML web pages but aren't familiar with creating dynamic, data driven web applications, you should consider learning ASP. And Sams Teach Yourself ASP.NET 2.0 in 24 Hours, Complete Starter Kit is the perfect learning tool. The Starter Kit provides the unbeatable combination of programmer/author Scott Mitchell and the step-by-step learning method of the best-selling Sams Teach Yourself series. The accompanying CD includes Visual Web Developer 2005 Express, a lightweight, easy-to-use and easy-to-learn web development tool, and all projects developed in the book's examples.

Table of contents

  1. Copyright
    1. Dedication
  2. About the Author
  3. Acknowledgments
  4. We Want to Hear from You!
  5. Introduction
    1. Conventions Used in This Book
  6. I. Getting Started with ASP.NET
    1. 1. Getting Started with ASP.NET 2.0
      1. What Is ASP.NET?
        1. Serving Static Web Pages
        2. Serving Dynamic Web Pages
        3. Hosting ASP.NET Web Pages
          1. Getting Started with a Web-Hosting Company
          2. 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 Markup Portion of an ASP.NET Web Page
        1. A Brief HTML Primer
          1. Extraneous Whitespace
          2. Nested Tags
          3. Case Sensitivity
        2. A Brief Look at XHTML
        3. 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
        1. Examining the Environment Settings
        2. Configuring the HTML Design-Time 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. Exercises
    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
        4. Completing the User Interface
      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
          1. Incrementing the Looping Variable by More Than One Each Loop Iteration
        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 HTML Markup Generated by the Label Web Control
        2. 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> 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 Source Code Portion 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 Aesthetic 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 Aesthetic 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. Aesthetic 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. Examining the GridView’s Rendered Markup
        3. Customizing the Appearance of the GridView
          1. Formatting from the Properties Window
          2. Formatting the GridView’s Fields
          3. Formatting with the Auto Format Dialog Box
      3. Showing One Record at a Time with the DetailsView
        1. Customizing the Paging Interface
        2. Customizing the Appearance of the DetailsView
        3. A Look at the DetailsView’s Markup
      4. Paging and Sorting with the GridView
        1. A Look at Paging
          1. Testing the Paging Functionality
          2. What’s Happening When Moving from One Page to Another?
          3. A Look at the Pagination Events
        2. Providing Sortable Data
          1. Customizing the Sorting Interface
          2. Closing Comments on Sorting
      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 Auto-Generated TextBox with a Custom Editing Interface
        4. Understanding Optimistic Concurrency
      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
          1. Laying Out Items Horizontally
      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
  9. IV. Site Navigation, User Management, and Page Layout
    1. 19. Defining a Site’s Structure 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 from the Site’s Structure
      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. 20. 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. Adjusting the Control’s Colors, Fonts, and Borders
          2. Specifying the Text for the Labels, Text Boxes, and Buttons
          3. 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. Recovering a User’s Forgotten Password
      6. Summary
      7. Q&A
      8. Workshop
        1. Quiz
        2. Answers
        3. Exercises
    3. 21. 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 an ASP.NET Page That Inherits the Master 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
  10. V. Building a Photo Album Web Application with ASP.NET
    1. 22. Devising a Plan for the Photo Album Application
      1. An Overview of the Design Process
      2. The Photo Album Application’s Design Requirements
        1. Describing the Requirements as Use Cases
          1. Supporting User Accounts
          2. Configuring the Photo Album’s Categories
          3. Uploading Pictures to the Website
          4. Viewing Pictures and Leaving Comments
      3. Creating the Database Structure
        1. Modeling Relationships in a Database
          1. Examining One-to-One Relationships
          2. Looking at One-to-Many Relationships
          3. Understanding Many-to-Many Relationships
        2. Enforcing Relationships with Foreign Key Constraints
        3. Enumerating the One-to-Many Relationships in the Photo Album Application Database
        4. Creating the User Account Tables
        5. Creating the Categories Table
          1. Adding the Foreign Key Constraint
        6. Defining the Structure of the Pictures Table
        7. Creating the Comments Table
      4. Sketching Mockups for the Application’s User Interface
      5. Summary
      6. Q&A
      7. Workshop
        1. Quiz
        2. Answers
        3. Exercises
    2. 23. Building the Photo Album Application Foundation
      1. Partitioning the Application into Manageable Tasks
        1. Adding a Simple Master Page
        2. Creating the Dummy Web Pages
      2. Implementing the User Account-Related Pages
        1. Allowing Visitors to Create User Accounts
        2. Providing a Login Page
        3. Adding Login Information to the Master Page
      3. Creating the Photo Album Website’s Home Page
        1. Adding and Configuring the SqlDataSource Control
        2. Displaying Links to the Photo Albums with a GridView
      4. Managing Categories
        1. Restricting Anonymous Users from Visiting the Administration Page
        2. Retrieving the List of Categories for the Logged-On User
        3. Adding a New Category
          1. Ensuring That the User Enters a Value for the Category Name
        4. Viewing, Editing, and Deleting Categories
      5. Summary
      6. Q&A
    3. 24. Uploading and Displaying Images and Leaving Comments
      1. Completing the Photo Album Administration Pages
        1. Adding New Images to the Photo Album
          1. Inserting the Picture Information in the Database
          2. Displaying a Drop-Down List of Categories
          3. Adding a -- None -- Item to the Drop-Down List
          4. Ensuring That the User Enters a Title and Description
          5. Uploading and Saving the Image File
          6. Ensuring That Only Image Files Are Uploaded
        2. Viewing, Editing, and Deleting Existing Pictures
          1. Displaying a Drop-Down List of Categories with a -- None -- Option
          2. Ensuring that the User Enters the Title and Description
          3. Making the UpdatedOn Field Read-Only
          4. Showing the Associated Image
          5. Deleting Pictures
          6. The Complete Source Code Portion
      2. Displaying the Photo Album to All Visitors
        1. Filtering the User’s Photo Album
          1. Retrieving the Filtered Pictures
          2. Displaying the Filtered Pictures
      3. Viewing an Individual Picture and Its Comments
        1. Allowing Authenticated Users to Add Comments
          1. Creating an Event Handler for a Nested Control
          2. Setting the INSERTed Values Programmatically
        2. Displaying Comments
      4. Defining the Site’s Structure and Providing Site Navigation
      5. Summary
      6. Q&A

Product information

  • Title: Sams Teach Yourself ASP.NET 2.0 in 24 Hours
  • Author(s): Scott Mitchell
  • Release date: March 2006
  • Publisher(s): Sams
  • ISBN: 0672327384