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

ASP.NET Kick Start

Book Description

Visual Studio .NET is the premier development environment for creating .NET applications. The environment includes specialized tools for working with databases, XML files, and XML Web services. Building applications with Visual Studio .NET is a very different experience than building ASP.NET applications with a standard text editor. Visual Studio .NET performs a lot of invisible work in the background, and the environment makes a number of assumptions about the best way to build applications. It is difficult for even an experienced ASP.NET developer to use Visual Studio .NET effectively without any guidance. This book helps readers understand and begin using this complicated environment.

Table of Contents

  1. Copyright
    1. Dedication
  2. About the Author
  3. Acknowledgments
  4. We Want to Hear from You!
  5. Introduction
    1. Who Should Read This Book?
    2. How This Book Is Organized
    3. What Do You Need to Know Before Reading This Book?
    4. Conventions Used in This Book
  6. I. Building Web Form Pages
    1. 1. Getting Familiar with the Development Environment
      1. Creating a Simple Web Forms Page
      2. Working with Solutions and Projects
        1. Creating Projects
        2. Creating Solutions
        3. Accessing Project Files
          1. Upgrading Existing Applications to Visual Studio .NET
          2. Working with Projects Offline
      3. Overview of Visual Studio .NET Windows
        1. Using Auto Hide
        2. Using the Start Page
        3. Using the Solution Explorer Window
          1. Adding Files and Folders to a Project
          2. Copying and Moving Items in a Project
        4. Displaying All Items in a Solution
        5. Copying a Project
        6. Using the Toolbox
          1. Controlling How Toolbox Items Are Displayed
          2. Adding New Items to the Toolbox
          3. Adding New Tabs to the Toolbox
        7. Using the Server Explorer
        8. Using the Properties Window
      4. Using the Visual Studio .NET Designer
      5. Using the Visual Studio .NET Code and Text Editor
        1. Taking Advantage of IntelliSense
        2. Navigating Code
          1. Using the Navigation Bar
          2. Moving to a Line Number
          3. Moving to a Definition
          4. Searching for Text
          5. Using Bookmarks
        3. Outlining Code
        4. Customizing the Code Editor
          1. Selecting Tab or Multiple Document Interface Mode
          2. Modifying the Code Editor Font
          3. Displaying Line Numbers
          4. Displaying the Code Editor in Full-Screen Mode
        5. Using the Task List Window
          1. Displaying Tasks for the Current File
          2. Adding Code Comments to the Task Lists
          3. Tracking Code Errors
          4. Adding User Comments
          5. Adding Shortcuts to the Task List
      6. Automatically Documenting Your Code
      7. Summary
    2. 2. Using the Visual Studio .NET Designer
      1. Creating a New HTML Page
        1. Previewing an HTML Page in a Browser
        2. Switching Between Design View and HTML View
        3. Setting the Target Schema Property
      2. Working with HTML Pages in Design View
        1. Selecting Flow or Grid Layout Mode
        2. Adding HTML Elements to a Page
        3. Designing an HTML Page in Flow Layout Mode
        4. Designing an HTML Page in Grid Layout Mode
          1. Displaying a Grid
          2. Using Snap to Grid
          3. Aligning Elements in Grid Layout Mode
          4. Layering Elements in Grid Layout Mode
        5. Mixing Flow and Grid Layout Modes
        6. Formatting Text
        7. Setting Background and Margin Properties
        8. Adding Images
        9. Adding Hypertext Links
          1. Adding a Bookmark
        10. Adding Form Elements
          1. Adding Text Fields
          2. Adding Password Fields
          3. Adding Text Areas
          4. Adding Radio Buttons
          5. Adding Check Boxes
          6. Adding Drop-Down Lists and List Boxes
          7. Adding Buttons
          8. Adding File Fields
          9. Adding Hidden Fields
        11. Adding Tables
        12. Adding Framesets
          1. Assigning Pages to Frames
          2. Linking to a Page in a Frame
          3. Modifying Frameset Properties
      3. Working with HTML Pages in HTML View
        1. Taking Advantage of Automatic Statement Completion
        2. Enabling and Disabling Automatic Formatting
        3. Validating HTML Documents
      4. Using the Document Outline
      5. Adding Client-Side Scripts
      6. Adding Style Sheets
        1. Adding Style Attributes Inline
        2. Adding a Style Block to a Page
        3. Creating External Style Sheets
      7. Summary
    3. 3. Creating Basic Web Form Pages
      1. Overview of Web Form Pages
        1. Creating a Simple Web Form Page
        2. The Two Parts of a Web Form Page
        3. Compiling and Viewing Web Form Pages
      2. Adding Server Controls
        1. Using HTML Controls
        2. Using Web Controls
        3. Adding Label Controls
        4. Adding Button Controls
        5. Adding TextBox Controls
        6. Adding List Controls
        7. Using the AutoPostBack Property
        8. Grouping Controls with Panels
        9. Formatting Web Controls
      3. Handling Events
        1. Handling Control Events
        2. Handling Page Events
          1. The IsPostBack Property
      4. Summary
    4. 4. Validating Web Form Pages
      1. Overview of the Validation Controls
        1. Post Backs and Form Validation
        2. JavaScript and the Validation Controls
      2. Using Validation Controls
        1. Checking for Required Fields
        2. Validating a Range of Expressions
        3. Comparing Values
      3. Performing Data Type Checks
        1. Regular Expression Validation
      4. Performing Custom Validation
        1. Displaying a Summary of Validation Errors
      5. Summary
    5. 5. Creating Web User Controls
      1. Creating a Simple Web User Control
      2. Handling Events in a Web User Control
      3. Building Form Elements with Web User Controls
      4. Dynamically Loading Web User Controls
      5. Summary
    6. 6. Debugging Your Web Form Pages
      1. Building Your Project
        1. Building in Debug and Release Mode
        2. Explicit and Dynamic Compilation
        3. Displaying Errors in Your Application
      2. Using the Visual Studio .NET Debugger
        1. Adding Breakpoints
        2. Stepping Through Code
        3. Debugger Windows
        4. Adding Watches
        5. Debugging and Exceptions
        6. Debugging Client-Side Script
        7. Debugging SQL
      3. Page and Application Tracing
        1. Using Page Tracing
          1. Placing Trace Messages in Different Categories
          2. Tracing and Exceptions
        2. Programmatically Enabling Tracing
        3. Using Application Tracing
      4. Summary
  7. II. Working with Database Data
    1. 7. Using the Visual Database Tools
      1. Visual Database Tools Support in Different Editions of Visual Studio .NET
      2. Working with Database Objects in Server Explorer
        1. Browsing Database Objects with Server Explorer
        2. Retrieving and Modifying Data with Server Explorer
        3. Creating New Databases with Server Explorer
        4. Creating New Database Tables with Server Explorer
        5. Creating New Database Views with Server Explorer
        6. Creating New Stored Procedures with Server Explorer
        7. Creating New Triggers with Server Explorer
        8. Creating New Database Functions with Server Explorer
      3. Designing Databases with Database Diagrams
        1. Creating a New Database Diagram
        2. Creating New Tables with Database Diagrams
        3. Controlling How Tables Are Displayed
        4. Visually Specifying Relationships
        5. Adding Annotations to a Database Diagram
        6. Controlling Page Breaks in a Database Diagram
      4. Working with Database Projects
        1. Creating a New Database Project
        2. Creating Database References
        3. Creating SQL Scripts
        4. Creating SQL Queries
      5. Summary
    2. 8. Overview of ADO.NET
      1. The Three Dualities of ADO.NET
        1. OleDb Versus SqlClient
        2. DataSets Versus DataReaders
        3. Relational Versus XML Views
      2. Creating Database Connections
      3. Using DataSets, DataAdapters, and DataViews
        1. Displaying Database Data with a DataSet
          1. Displaying All Rows with a DataSet
          2. Using a Typed DataSet
        2. Using DataViews
      4. Using DataReaders and Commands
        1. Displaying Database Data with a DataReader
      5. Caching Data for Better Performance
        1. Using the Cache Object
        2. Caching a DataSet in Memory
      6. Summary
    3. 9. Saving Form Data
      1. Overview of the Command Object
        1. Creating an SqlCommand Object
        2. Creating an OleDbCommand Object
      2. Executing Commands with Parameters
        1. Using Parameters with the SqlCommand Object
        2. Using Parameters with the OleDbCommand Object
      3. Executing Commands with Stored Procedures
        1. Executing a Simple Stored Procedure
        2. Stored Procedures and Return Values
        3. Stored Procedures and Output Parameters
      4. Creating a Pizza Order Form
      5. Summary
    4. 10. Using List Controls
      1. Overview of the List Controls
        1. Adding List Items with the ListItem Collection Editor
        2. Adding List Items Programmatically
        3. Adding List Items with Databinding
        4. Retrieving the Selected List Item
        5. Enabling AutoPostBack
      2. Displaying Database Data in a List Control
      3. Working with Multi-Select List Controls
      4. Advanced List Control Topics
        1. Adding a Default List Item
        2. Displaying a Default List Item
        3. Creating Interactions Between List Controls
      5. Summary
    5. 11. Displaying Data with the Repeater Control
      1. Binding the Repeater Control to Database Data
      2. Using Templates with the Repeater Control
      3. Formatting the Output of a Databinding Expression
      4. Loading Templates from an External File
      5. Adding Child Controls to the Repeater Control
      6. Summary
    6. 12. Displaying Data with the DataList Control
      1. Binding the DataList Control to Database Data
        1. Using Templates with the DataList Control
      2. Formatting the Appearance of a DataList
        1. Formatting the Borders in a DataList Control
        2. Using Auto Formatting with the DataList Control
        3. Creating a Multicolumn DataList
      3. Creating a Menu with a DataList
        1. Using the DataKeys Collection
      4. Creating a Single-Page Master/Detail Form
      5. Summary
    7. 13. Displaying Data with the DataGrid Control
      1. Automatically Displaying the Contents of a Database Table
      2. Customizing the Appearance of the DataGrid Control
        1. Applying Auto Formatting to a DataGrid
        2. Specifying Columns in a DataGrid
        3. Displaying HyperLink Columns in a DataGrid
      3. Sorting Data in a DataGrid
        1. Using Caching with Sorting
        2. Performing Ascending and Descending Sorts
      4. Paging Through Records in a DataGrid
        1. Customizing the Paging User Interface
        2. Using Caching with Paging
      5. Editing Database Records in a DataGrid
        1. Editing with Bound Columns
        2. Adding a Delete Button to the DataGrid Control
        3. Using Smart Navigation with a DataGrid
        4. Editing with Template Columns
      6. Summary
  8. III. Working with ASP.NET Applications
    1. 14. Improving Application Performance with Caching
      1. Using Page Output Caching
        1. Using the VaryByParam Attribute
        2. Using Controls in a Cached Page
        3. Using the VaryByHeader Attribute
        4. Using the VaryByCustom Attribute
        5. Specifying the Cache Location
      2. Using Partial Page Caching
        1. Using Controls in a Cached Web User Control
        2. Using Properties in a Cached User Control
      3. Using Data Caching
        1. Adding and Removing Items from the Cache
        2. Using File Dependencies
        3. Using Expiration Policies
        4. Setting Item Priorities
      4. Summary
    2. 15. Configuring Your Application
      1. Overview of the Machine.Config and Web.Config Files
      2. Configuration Sections
        1. The <configSections> Section
        2. The <appSettings> Section
        3. The <system.diagnostics> Section
        4. The <system.net> Section
        5. The <system.web> Section
        6. The <trace> Element
        7. The <globalization> Element
        8. The <httpRuntime> Element
        9. The <compilation> Section
        10. The <pages> Element
        11. The <customErrors> Section
        12. The <authentication> Section
        13. The <identity> Element
        14. The <authorization> Section
        15. The <machineKey> Element
        16. The <securityPolicy> Section
        17. The <sessionState> Element
        18. The <httpHandlers> Section
        19. The <httpModule> Section
        20. The <processModel> Element
        21. The <webControls> Element
        22. The <clientTarget> Section
        23. The <browserCaps> Section
        24. The <webServices> Section
      3. Adding Custom Configuration Information
        1. Using the <appSettings> Section
        2. Creating a Custom Section Handler
      4. Advanced Configuration Topics
        1. Applying Configuration Settings to a Particular File
        2. Locking Configuration Settings
      5. Summary
    3. 16. Securing Your Application
      1. Overview of Forms Authentication
        1. Authentication and Authorization
      2. Enabling Forms Authentication
        1. Creating a Simple Login Page
        2. Retrieving the Username
        3. Creating a Sign Out Link
      3. Storing Usernames and Passwords in the Web.Config File
      4. Storing Usernames and Passwords in a Database Table
        1. Adding a Registration Page
      5. Implementing Custom Roles with Forms Authentication
      6. Summary
    4. 17. Maintaining Application State
      1. Using View State
        1. How View State Really Works
        2. Disabling View State
        3. Adding Custom Information to View State
        4. Protecting View State
      2. Using Session State
        1. Configuring Out-of-Process Session State
          1. Storing Session State in a Windows Service
          2. Storing Session State in a SQL Server Database
        2. Enabling Cookieless Sessions
      3. Using Application State
      4. Summary
    5. 18. Handling Application-Wide Events
      1. Using the Global.asax File
        1. Handling Application-Wide Errors
        2. Rewriting Page Requests
        3. Detecting the Start and End of a User Session
        4. Implementing Custom Caching
      2. Using Custom HttpModules
        1. Creating the Cookieless Authentication Modules
        2. Creating the Performance Logging Module
      3. Summary
    6. 19. Deploying Your Application
      1. Web Application Deployment Overview
        1. Things You Should Check Before Deployment
      2. Creating Web Setup Projects
        1. Modifying Properties of a Web Setup Project
        2. Modifying the User Interface of the Web Setup Project
      3. Summary
  9. IV. Components, Web Services, and Custom Controls
    1. 20. Building Business Components
      1. Why Use Components?
      2. Components Versus Classes
      3. Creating a Simple Component
        1. Creating Components with Static/Shared Methods
        2. Adding Properties to a Component
      4. Creating a Database Component
        1. Using DataReaders with Components
      5. Creating Multi-Tiered Applications
      6. Creating a Library of Components
        1. Adding Components to the Toolbox
      7. Accessing the Current HttpContext in a Component
      8. Summary
    2. 21. Building XML Web Services
      1. What Is a Web Service?
        1. ASP.NET Web Services
      2. Creating a Simple ASP.NET Web Service
        1. Invoking a Web Service from a Web Form Page
        2. Web Services and Namespaces
      3. Exposing Database Data Through a Web Service
      4. Exposing a Custom Object Through a Web Service
      5. Advanced Web Service Topics
        1. Handling Errors When Calling Web Methods
        2. Caching the Output of Web Methods
        3. Using Dynamic Discovery
      6. Summary
    3. 22. Creating Custom Web Form Controls
      1. Custom Web Form Controls Versus Web User Controls
      2. Overview of Custom Web Form Controls
      3. Creating a Simple Non-Composite Control
        1. Using the HtmlTextWriter Class
        2. Creating a Non-Composite Content Rotator Control
      4. Creating a Simple Composite Control
        1. Using the INamingContainer Interface
        2. Using Render with Composite Controls
        3. Composite Controls and Designer Support
        4. Creating a Composite Address Form Control
      5. Adding Designer Support to a Custom Web Form Control
        1. Using Design-Time Attributes
        2. Controlling the Appearance of a Custom Control in the Toolbox
        3. Using the ControlDesigner Class
      6. Summary