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

C# Web Development with ASP.NET: Visual QuickStart Guide

Book Description

C# was developed from the ground up to serve as the main language for Microsoft's new .NET framework--and to compete with Java. C# Web Development for ASP.NET: Visual QuickStart Guide is aimed at beginning developers who may have experience with scripting languages but are not necessarily experienced with object-oriented languages. Using task-based examples and hundreds of screenshots, all code examples are presented in the context of ASP.NET development, aimed at Web developers. While C# Web Development for ASP.NET: Visual QuickStart Guide does not attempt to teach everything about the .NET Framework, it clearly explains all you need to know to get up and running with the C# language.

Table of Contents

  1. Copyright
    1. Dedication
  2. Acknowledgments
  3. Introduction
    1. .NET Framework Gossip
    2. What Is the .NET Framework?
    3. So What Is C#?
    4. ASP.NET
    5. What Is this Book About?
    6. Whom Is this Book For?
    7. About the Author
    8. What You Need in Order to Learn C#
    9. Final Thoughts
  4. 1. Getting Started
    1. Getting C#
      1. To download and install the .NET framework:
    2. Installing Internet Information Services (IIS)
      1. To install IIS:
    3. Creating a Web Project with Visual Studio .NET
      1. To create an ASP.NET application with Visual Studio .NET:
    4. Debugging Web Projects with Visual Studio .NET
      1. To debug a Web application using VS .NET:
    5. Writing a Simple ASP .NET Page
      1. To author ASP .NET applications without VS .NET:
    6. Debugging ASP .NET Applicatons
      1. To debug ASP .NET applications:
    7. Running the Compiler Manually
      1. Using the command-line compiler:
    8. Compiling and Executing C# Programs without VS .NET
      1. To run the C# command line compiler:
    9. Debugging Applications Outside VS .NET
      1. To use the SDK debugger:
  5. 2. C# Building Blocks
    1. Working with C# Building Blocks
      1. To create a test project for this chapter:
    2. Writing C# Code
      1. To write C# code:
    3. Declaring Variables
      1. To declare a variable:
    4. Defining Constants
      1. To define a constant:
    5. Grouping Constants into Enumerated Types
      1. To declare an enumerated type:
    6. Declaring Functions
      1. To declare a function that takes no input and doesn’t return a value:
    7. Declaring Functions with Parameters
      1. To declare parameters:
    8. Returning Function Values
      1. To return a value from a function:
    9. Defining a Class
      1. To declare a class:
    10. Adding Classes to the Sample Application
      1. To add classes to the sample application:
    11. Creating and Using Objects
      1. To create an object and use it:
    12. Creating Objects in the Sample Application
      1. To create objects in the sample application:
    13. Including Class Definitions from Outside Sources
      1. To reference another assembly:
    14. Grouping Classes into Namespaces
      1. To add a namespace:
    15. Adding Fields to Classes
      1. To add a field to a class:
    16. Initializing Fields in Place
      1. To add field initializers:
    17. Adding Properties to Classes
      1. To add a property to the class:
    18. Adding Methods to Classes
      1. To add an instance method:
    19. Adding Members to the Classes in the Sample Code
      1. To add members to the classes in the sample code:
    20. Completing the Sample Application
      1. To connect the ToDoList to ToDoItems:
      2. To display the items in the task list:
    21. Adding Comments
      1. To add inline comments:
      2. To add block comments:
    22. Understanding Parameter Direction for Reference Types
  6. 3. Conditionals and Loops
    1. Working with Loops and Conditionals
      1. To create a test project for this chapter:
    2. Comparing Numeric Types
      1. To compare two numeric types:
    3. Comparing Reference Types
      1. To compare two reference variables for identity:
      2. To compare two reference variables for equivalence:
    4. Combining Test Clauses
      1. To combine multiple clauses in the same statement:
    5. Writing if-else Statements
      1. To write an if-else statement:
    6. Testing Multiple Conditions with switch
      1. To write a switch statement:
    7. Conditional Operator
      1. To use the conditional operator:
    8. Adding Conditional Statements to the Sample Program
      1. To add conditional statements to the sample application:
    9. Using while Loops
      1. To write a while loop:
    10. Using do Loops
      1. To write a do loop:
    11. Using for Loops
      1. To write a for loop that executes for a specified number of times:
    12. Exiting and Continuing Loops
      1. To use the break command:
      2. To advance the loop:
      3. To jump to another part of the code:
    13. Adding Loops to the Sample Program
      1. To add loops to the sample application:
  7. 4. Strings
    1. Preparing Your Machine to Work with Strings
      1. To prepare your machine to run the database samples:
    2. Working with Strings
      1. To create a test project for this chapter:
    3. Initializing Strings
      1. To declare and initialize a string variable:
    4. Comparing Strings
      1. To perform a case-sensitive test for equality:
      2. To perform a case-insensitive, dictionary-based string comparison:
      3. To perform a case-sensitive, ASCII-based string comparison:
    5. Concatenating Strings
      1. To build one string from the combination of two or more strings:
    6. Finding the String Length
      1. To find the length of a string:
    7. Comparing and Concatenating Strings in the Sample Application
      1. To implement the login screen:
    8. Creating Strings from Characters
      1. To create a string by repeating a character a number of times:
      2. To create a string from an array of characters:
    9. Using Escape Characters
      1. To use special characters in your string:
    10. Using Literal Strings
      1. To create a literal string:
    11. Accessing the String’s Characters
      1. To access the characters of a string:
    12. Finding a Substring within a String
      1. To find the first or last occurrence of a character within the string:
    13. Extracting Part of the String
      1. To extract part of a string based on indices:
    14. Splitting a String
      1. To split strings into an array of substrings:
    15. Joining a String
      1. To create a string by joining other strings:
    16. Uppercasing and Lowercasing
      1. To produce a string in either uppercase or lowercase form:
    17. Formatting Strings
      1. To format strings:
    18. Finishing the Sample Application
      1. To finish the sample application:
    19. Representing Objects as Strings
      1. To implement your own ToString function:
    20. Allocating Strings with StringBuilder
      1. To create strings with StringBuilder:
  8. 5. Class Inheritance
    1. Working with Class Inheritance
      1. To create a test project for this chapter:
    2. Inheriting a Class from Another
      1. To inherit a class from another:
    3. Exposing and Restricting Access to Members
      1. To change the scope of a member:
    4. Enhancing the Sample Application
      1. To add a client-side script to the WorkOrder form:
      2. To create a generic class to encapsulate Page_Load:
    5. Hiding Methods from the Base Class
      1. To suppress the warning resulting from hiding:
    6. Overriding Functions in a Derived Class
      1. To override functions from a base class:
    7. Adding a Generic Button to the Sample Application
      1. To create a generic button class:
    8. Using the Generic Button in the WorkOrder Form
      1. To replace all buttons on the WorkOrder form with NewButton:
    9. Adding Functions that Must Be Overridden
      1. To add a function that must be overridden:
    10. Requiring Inheritance
      1. To require inheritance in your class:
    11. Blocking Inheritance
      1. To block inheritance:
  9. 6. Special Members
    1. Adding Functions with the Same Name (Method Overloading)
      1. To do method overloading:
    2. Defining Functions with a Variable Number of Parameters
      1. To add a function that accepts a variable number of parameters:
    3. Adding Constructors
      1. To add a constructor:
    4. Invoking Base Constructors
      1. To invoke a base constructor:
    5. Adding Finalizers
      1. To add a finalizer:
    6. Building Code Libraries with Static Members
      1. To add and call static members:
    7. Redefining the Meaning of Operators (Operator Overloading)
      1. To overload a unary operator:
      2. To overload a binary operator:
    8. Redefining Equality by Overriding ==
      1. To override the == operator:
      2. To override the != operator:
    9. Redefining Equality by Overriding Equals
      1. To override the Equals and GetHashCode functions:
    10. Working with Special Members
      1. To write a class that reads configuration information:
      2. To enhance the class to read from any custom configuration section:
  10. 7. Types
    1. Working with Types
      1. To create a test project for this chapter:
    2. Obtaining a Class’s Type
      1. To obtain a Type object from an object:
      2. To obtain a Type object from a class (without creating an object):
    3. Testing for Type Compatibility
      1. To test if an object is compatible with a type:
    4. Converting From One Type to Another (Casting)
      1. To cast one type into another using explicit casts:
      2. To cast using the as operator:
    5. Extending the Sample Application
      1. To extend the sample application:
    6. Defining Casting Rules (Cast Operator Overloading)
      1. To define an explicit cast operator:
  11. 8. Interfaces
    1. Working with Interfaces
      1. To write a custom module:
    2. Defining Interfaces
      1. To define an interface:
    3. Implementing Interface Members Implicitly
      1. To implement an interface implicitly:
    4. Implementing Interface Members Explicitly
      1. To implement an interface explicitly:
    5. Enhancing the Sample Application
      1. To add a custom module class:
    6. Using Objects through Interfaces
      1. To use a class through an interface:
    7. Interface Discovery
      1. To discover if an object supports the interface:
    8. Using Interfaces for Polymorphism
      1. To use polymorphism:
    9. Deriving One Interface from Another
      1. To derive one interface from another:
    10. Refactoring
      1. To refactor classes using interfaces:
    11. Re-Implementing Interfaces in a Derived Class
      1. To re-implement the interface in a derived class:
    12. Finishing the Sample Application
      1. To activate the custom module for your application:
      2. To finish the dimensions.aspx page:
  12. 9. Arrays and Collections
    1. Working with Arrays and Collections
      1. To create a test project for this chapter:
    2. Creating Arrays of Valuetypes
      1. To allocate and use an array of valuetypes:
    3. Creating Arrays of Reference Types
      1. To create an array of objects:
    4. Navigating through the Array
      1. To navigate through the array using the index number:
      2. To navigate through the array using the foreach command:
    5. Initializing Array Elements in Place
      1. To initialize an array in place:
    6. Creating Multi-Dimensional Arrays
      1. To create a two-dimensional array:
    7. Enhancing the Sample Application
      1. To add support for the cell array:
    8. Finding Array Elements Using Linear Searches
      1. To search through an array linearly:
    9. Sorting Arrays
      1. To sort the elements of an array:
    10. Finding Array Elements Using Binary Searches
      1. To perform a binary search:
    11. Making Classes Behave Like Arrays (Adding Indexers)
      1. To add an indexer to your class:
    12. Adding Indexers to the Sample Application
      1. To add an indexer to the sample code:
    13. Copying an Array
      1. To copy the elements from one array into another:
    14. Creating Dynamic Lists
      1. To create an ArrayList:
    15. Creating Queues
      1. To create a queue, add items to it, and remove items from it:
    16. Creating Stacks
      1. To create a stack, add items to it, and remove items from it:
    17. Creating HashTables
      1. To create a HashTable:
    18. Navigating through HashTables
      1. To navigate through all the items in a HashTable:
    19. Finishing the Sample Application
      1. To finish the sample application:
    20. Testing the CodeGridWebControl
      1. To test the sample application:
  13. 10. Delegates and Events
    1. Working with Delegates and Events
      1. To create a test project for this chapter:
    2. Declaring a Delegate
      1. To declare a delegate:
    3. Creating and Invoking Delegates
      1. To create a delegate:
      2. To invoke a delegate:
    4. Combining Delegates
      1. To combine two delegates:
    5. Removing Delegates
      1. To remove a delegate from a combined delegate:
    6. Declaring and Firing Events
      1. To declare an event:
      2. To fire the event:
    7. Adding Events that are Web Friendly
      1. To declare an event that has a standard format:
    8. Subscribing to Events
      1. To subscribe to an event:
    9. Firing Delegates Asynchronously
      1. To execute a delegate function asynchronously and wait:
      2. To execute a delegate function asynchronously and let the system tell you when it is done:
    10. Waiting for Asynchronous Delegates to Complete
      1. To wait for several delegates to complete executing:
    11. Retrieving Results from Asynchronous Delegates
      1. To retrieve output parameters if you have code that waits for the delegates to finish:
      2. To retrieve output parameters if you have a callback function:
    12. Finishing the Sample Application
      1. To complete the sample application:
  14. 11. Error Handling
    1. Working with Exceptions
      1. To start the sample application:
    2. Catching Exceptions
      1. To catch all possible exceptions:
    3. Catching Specific Exceptions
      1. To catch a specific exception:
    4. Obtaining Exception Information
      1. To extract exception information:
    5. Working with Exception Chains
      1. To navigate through an exception chain:
    6. Declaring Your Own Exceptions
      1. To declare an exception class:
    7. Setting the Error Message
      1. To set the error message for custom error classes:
    8. Generating an Exception
      1. To throw an exception:
    9. Catching and Re-throwing Exceptions
      1. To reactivate the exception for the caller:
    10. Building an Exception Chain
      1. To build an exception chain:
    11. Adding Code that Executes Before Exiting the Function
      1. To add a finally block:
    12. Using using
      1. To use an object with the using statement:
    13. Adding Form Security to the Sample Application
      1. To add form security to the sample application:
    14. Handling Unhandled Errors in Web Applications
      1. To add error catching in the sample application:
  15. 12. Reflection and Attributes
    1. Working with Reflection and Attributes
      1. To start working on the sample application:
    2. Identifying an Assembly
    3. Working with Display Names
      1. To build the display name for an assembly in the GAC:
    4. Working with Path Strings
      1. To identify assemblies using path strings:
    5. Loading a Program Dynamically with a Display String
      1. To load a program using its display name:
    6. Loading a Program Dynamically with a Path String
      1. To load a program using its path:
    7. Instantiating a Class in the Assembly
      1. To create an instance of a class in an assembly:
    8. Enumerating Through the Classes in an Assembly
      1. To enumerate through all classes in an assembly:
    9. Listing the Members of a Class
      1. To obtain the members of a class:
    10. Setting or Getting a Field Dynamically
      1. To set or get the value of a field at runtime:
    11. Invoking a Method Dynamically
      1. To invoke a method dynamically at runtime:
    12. Completing Task One in the Sample Application
      1. To complete task one in the sample application:
    13. Applying Attributes to Code
      1. To apply attributes to code elements.
    14. Defining Attributes
      1. To define a custom attribute:
    15. Searching Code for Attributes
      1. To search for custom attributes:
    16. Completing Task Two in the Sample Application
      1. To finish task two in the sample application:
  16. 13. C# Web Projects
    1. Creating a DLL Project with Visual Studio .NET
      1. To create a DLL in VS.NET:
    2. Referencing and Executing DLL Code
      1. To reference a DLL from a Web application:
    3. Making DLLs Globally Available
      1. To digitally sign a DLL and add it to the GAC:
    4. Creating Web Services
      1. To create a Web Service:
    5. Consuming Web Services
      1. To use a Web Service: