Microsoft QuickStart Tutorial
Quickstart Tutorials
Hide TOC | I want my samples in...
VB.NET
Welcome | ASP.NET | WinForms | Common Tasks | LateBreaking
Add To "My Favorites"
Getting Started Introduction
Welcome to the ASP.NET QuickStart Tutorial
What is ASP.NET? Language Support
ASP.NET Web Forms Introducing Web Forms Working with Server Controls
The ASP.NET QuickStart is a series of ASP.NET samples and supporting commentary designed to quickly acquaint developers with the syntax, architecture, and power of the ASP.NET Web programming framework. The QuickStart samples are designed to be short, easy-to-understand illustrations of ASP.NET features. By the time you have completed the QuickStart tutorial, you will be familiar with: ●
Applying Styles to Controls Server Control Form Validation Web Forms User Controls Data Binding Server Controls
●
●
ASP.NET Syntax. While some of the ASP.NET syntax elements will be familiar to veteran ASP developers, several are unique to the new framework. The QuickStart samples cover each element in detail. ASP.NET Architecture and Features. The QuickStart introduces the features of ASP.NET that enable developers to build interactive, world-class applications with much less time and effort than ever before. Best Practices. The QuickStart samples demonstrate the best ways to exercise the power of ASP.NET while avoiding potential pitfalls along the way.
Server-Side Data Access Data Access and Customization Working with Business Objects Authoring Custom Controls
What Level of Expertise Is Assumed in the QuickStart? If you have never developed Web pages before, the QuickStart is not for you. You should be fluent in HTML and general Web development terminology. You do not need previous ASP experience, but you should be familiar with the concepts behind interactive Web pages, including forms, scripts, and data access.
Web Forms Controls Reference Web Forms Syntax Reference
ASP.NET Web Services
Working with the QuickStart Samples The QuickStart samples are best experienced in the order in which they are presented. Each sample builds on concepts discussed in the preceding sample. The sequence begins with a simple form submittal and builds up to integrated application scenarios.
Introducing Web Services Writing a Simple Web Service Web Service Type Marshalling Using Data in Web Services Using Objects and Intrinsics The WebService Behavior HTML Pattern Matching
ASP.NET Web Applications Application Overview Using the Global.asax File Managing Application State HttpHandlers and Factories
Cache Services Caching Overview Page Output Caching Page Fragment Caching Page Data Caching
Configuration Configuration Overview Configuration File Format Retrieving Configuration
Deployment Deploying Applications Using the Process Model Handling Errors
Security Security Overview Authentication & Authorization Windows-based Authentication Forms-based Authentication Authorizing Users and Roles User Account Impersonation Security and WebServices
http://samples.gotdotnet.com/quickstart/aspplus/ (1 of 2) [4/02/2002 8:50:06 AM]
Microsoft QuickStart Tutorial Localization Internationalization Overview Setting Culture and Encoding Localizing ASP.NET Applications Working with Resource Files
Tracing Tracing Overview Trace Logging to Page Output Application-level Trace Logging
Debugging The SDK Debugger
Performance Performance Overview Performance Tuning Tips Measuring Performance
ASP to ASP.NET Migration Migration Overview Syntax and Semantics Language Compatibility COM Interoperability Transactions
Sample Applications A Personalized Portal An E-Commerce Storefront A Class Browser Application IBuySpy.com Get URL for this page
http://samples.gotdotnet.com/quickstart/aspplus/ (2 of 2) [4/02/2002 8:50:06 AM]
Microsoft ASP.NET QuickStarts Tutorial
Getting Started
Welcome to the ASP.NET QuickStart Tutorial
Introduction What is ASP.NET? Language Support
ASP.NET Web Forms Introducing Web Forms
The ASP.NET QuickStart is a series of ASP.NET samples and supporting commentary designed to quickly acquaint developers with the syntax, architecture, and power of the ASP.NET Web programming framework. The QuickStart samples are designed to be short, easy-to-understand illustrations of ASP.NET features. By the time you have completed the QuickStart tutorial, you will be familiar with:
Working with Server Controls Applying Styles to Controls
●
Server Control Form Validation Web Forms User Controls Data Binding Server Controls
●
Server-Side Data Access Data Access and Customization Working with Business Objects Authoring Custom Controls
●
ASP.NET Syntax. While some of the ASP.NET syntax elements will be familiar to veteran ASP developers, several are unique to the new framework. The QuickStart samples cover each element in detail. ASP.NET Architecture and Features. The QuickStart introduces the features of ASP.NET that enable developers to build interactive, world-class applications with much less time and effort than ever before. Best Practices. The QuickStart samples demonstrate the best ways to exercise the power of ASP.NET while avoiding potential pitfalls along the way.
Web Forms Controls Reference Web Forms Syntax Reference
ASP.NET Web Services Introducing Web Services Writing a Simple Web Service Web Service Type Marshalling Using Data in Web Services Using Objects and Intrinsics The WebService Behavior HTML Pattern Matching
What Level of Expertise Is Assumed in the QuickStart? If you have never developed Web pages before, the QuickStart is not for you. You should be fluent in HTML and general Web development terminology. You do not need previous ASP experience, but you should be familiar with the concepts behind interactive Web pages, including forms, scripts, and data access. Working with the QuickStart Samples The QuickStart samples are best experienced in the order in which they are presented. Each sample builds on concepts discussed in the preceding sample. The sequence begins with a simple form submittal and builds up to integrated application scenarios.
ASP.NET Web Applications Application Overview Using the Global.asax File Managing Application State HttpHandlers and Factories
Cache Services Caching Overview Page Output Caching Page Fragment Caching Page Data Caching
Configuration Configuration Overview Configuration File Format Retrieving Configuration
Deployment Deploying Applications Using the Process Model
http://samples.gotdotnet.com/quickstart/aspplus/doc/default.aspx (1 of 2) [4/02/2002 8:50:08 AM]
Microsoft ASP.NET QuickStarts Tutorial
Handling Errors
Security Security Overview Authentication & Authorization Windows-based Authentication Forms-based Authentication Authorizing Users and Roles User Account Impersonation Security and WebServices
Localization Internationalization Overview Setting Culture and Encoding Localizing ASP.NET Applications Working with Resource Files
Tracing Tracing Overview Trace Logging to Page Output Application-level Trace Logging
Debugging The SDK Debugger
Performance Performance Overview Performance Tuning Tips Measuring Performance
ASP to ASP.NET Migration Migration Overview Syntax and Semantics Language Compatibility COM Interoperability Transactions
Sample Applications A Personalized Portal An E-Commerce Storefront A Class Browser Application IBuySpy.com Get URL for this page
http://samples.gotdotnet.com/quickstart/aspplus/doc/default.aspx (2 of 2) [4/02/2002 8:50:08 AM]
Microsoft ASP.NET QuickStarts Tutorial
Getting Started
What is ASP.NET?
Introduction What is ASP.NET? Language Support
ASP.NET is a programming framework built on the common language runtime that can be used on a server to build powerful Web applications. ASP.NET offers several important advantages over previous Web development models:
ASP.NET Web Forms Introducing Web Forms
●
Working with Server Controls Applying Styles to Controls Server Control Form Validation Web Forms User Controls Data Binding Server Controls
●
Server-Side Data Access Data Access and Customization Working with Business Objects Authoring Custom Controls Web Forms Controls Reference
●
Web Forms Syntax Reference
ASP.NET Web Services Introducing Web Services Writing a Simple Web Service Web Service Type Marshalling Using Data in Web Services Using Objects and Intrinsics
●
The WebService Behavior HTML Pattern Matching
ASP.NET Web Applications Application Overview Using the Global.asax File Managing Application State
●
HttpHandlers and Factories
Cache Services Caching Overview Page Output Caching Page Fragment Caching Page Data Caching ●
Configuration Configuration Overview Configuration File Format Retrieving Configuration
Deployment Deploying Applications Using the Process Model
●
Enhanced Performance. ASP.NET is compiled common language runtime code running on the server. Unlike its interpreted predecessors, ASP.NET can take advantage of early binding, just-in-time compilation, native optimization, and caching services right out of the box. This amounts to dramatically better performance before you ever write a line of code. World-Class Tool Support. The ASP.NET framework is complemented by a rich toolbox and designer in the Visual Studio integrated development environment. WYSIWYG editing, drag-anddrop server controls, and automatic deployment are just a few of the features this powerful tool provides. Power and Flexibility. Because ASP.NET is based on the common language runtime, the power and flexibility of that entire platform is available to Web application developers. The .NET Framework class library, Messaging, and Data Access solutions are all seamlessly accessible from the Web. ASP.NET is also languageindependent, so you can choose the language that best applies to your application or partition your application across many languages. Further, common language runtime interoperability guarantees that your existing investment in COM-based development is preserved when migrating to ASP.NET. Simplicity. ASP.NET makes it easy to perform common tasks, from simple form submission and client authentication to deployment and site configuration. For example, the ASP.NET page framework allows you to build user interfaces that cleanly separate application logic from presentation code and to handle events in a simple, Visual Basic - like forms processing model. Additionally, the common language runtime simplifies development, with managed code services such as automatic reference counting and garbage collection. Manageability. ASP.NET employs a text-based, hierarchical configuration system, which simplifies applying settings to your server environment and Web applications. Because configuration information is stored as plain text, new settings may be applied without the aid of local administration tools. This "zero local administration" philosophy extends to deploying ASP.NET applications as well. An ASP.NET application is deployed to a server simply by copying the necessary files to the server. No server restart is required, even to deploy or replace running compiled code. Scalability and Availability. ASP.NET has been designed with scalability in mind, with features specifically tailored to improve performance in clustered and multiprocessor environments. Further, processes are closely monitored and managed by the ASP.NET runtime, so that if one misbehaves (leaks, deadlocks), a new process can be created in its place, which helps keep your application constantly available to handle requests. Customizability and Extensibility. ASP.NET delivers a wellfactored architecture that allows developers to "plug-in" their code at the appropriate level. In fact, it is possible to extend or replace any subcomponent of the ASP.NET runtime with your own custom-
http://samples.gotdotnet.com/quickstart/aspplus/doc/whatisaspx.aspx (1 of 2) [4/02/2002 8:50:09 AM]
Microsoft ASP.NET QuickStarts Tutorial
written component. Implementing custom authentication or state services has never been easier.
Handling Errors
Security Security Overview Authentication & Authorization Windows-based Authentication Forms-based Authentication
●
Security. With built in Windows authentication and perapplication configuration, you can be assured that your applications are secure.
The remainder of the QuickStart presents practical examples of these concepts.
Authorizing Users and Roles User Account Impersonation Security and WebServices
Localization Internationalization Overview Setting Culture and Encoding Localizing ASP.NET Applications Working with Resource Files
Tracing Tracing Overview Trace Logging to Page Output Application-level Trace Logging
Debugging The SDK Debugger
Performance Performance Overview Performance Tuning Tips Measuring Performance
ASP to ASP.NET Migration Migration Overview Syntax and Semantics Language Compatibility COM Interoperability Transactions
Sample Applications A Personalized Portal An E-Commerce Storefront A Class Browser Application IBuySpy.com Get URL for this page
http://samples.gotdotnet.com/quickstart/aspplus/doc/whatisaspx.aspx (2 of 2) [4/02/2002 8:50:09 AM]
Microsoft ASP.NET QuickStarts Tutorial
Getting Started
Introducing Web Forms
Introduction What is ASP.NET?
What is ASP.NET Web Forms?
Language Support
Writing Your First Web Forms Page Using ASP <%%> Render Blocks
ASP.NET Web Forms
Introduction to Server Controls
Introducing Web Forms
Handling Server Control Events
Working with Server Controls
Using Custom Server Controls
Applying Styles to Controls
Lists, Data, and Databinding
Server Control Form Validation
Form Validation Controls
Web Forms User Controls
Code-Behind Web Forms
Data Binding Server Controls
Section Summary
Server-Side Data Access Data Access and Customization Working with Business Objects
What is ASP.NET Web Forms?
Authoring Custom Controls Web Forms Controls Reference Web Forms Syntax Reference
ASP.NET Web Services Introducing Web Services Writing a Simple Web Service Web Service Type Marshalling
The ASP.NET Web Forms page framework is a scalable common language runtime programming model that can be used on the server to dynamically generate Web pages. Intended as a logical evolution of ASP (ASP.NET provides syntax compatibility with existing pages), the ASP.NET Web Forms framework has been specifically designed to address a number of key deficiencies in the previous model. In particular, it provides:
Using Data in Web Services Using Objects and Intrinsics
●
The WebService Behavior HTML Pattern Matching
●
●
ASP.NET Web Applications
The ability to create and use reusable UI controls that can encapsulate common functionality and thus reduce the amount of code that a page developer has to write. The ability for developers to cleanly structure their page logic in an orderly fashion (not "spaghetti code"). The ability for development tools to provide strong WYSIWYG design support for pages (existing ASP code is opaque to tools).
Application Overview Using the Global.asax File Managing Application State HttpHandlers and Factories
Cache Services Caching Overview Page Output Caching Page Fragment Caching Page Data Caching
This section of the QuickStart provides a high-level code walkthrough of some key ASP.NET Web Forms features. Subsequent sections of the QuickStart drill down into more specific details.
Writing Your First Web Forms Page ASP.NET Web Forms pages are text files with an .aspx file name extension. They can be deployed throughout an IIS virtual root directory tree. When a browser client requests .aspx resources, the ASP.NET runtime parses and compiles the target file into a .NET Framework class. This class can then be used to dynamically process incoming requests. (Note that the .aspx file is compiled only the first time it is accessed; the compiled type instance is then reused across multiple requests).
Configuration Configuration Overview Configuration File Format Retrieving Configuration
An ASP.NET page can be created simply by taking an existing HTML file and changing its file name extension to .aspx (no modification of code is required). For example, the following sample demonstrates a simple HTML page that collects a user's name and category preference and then performs a form postback to the originating page when a button is clicked:
Deployment Deploying Applications Using the Process Model
http://samples.gotdotnet.com/quickstart/aspplus/doc/webformsintro.aspx (1 of 7) [4/02/2002 8:50:18 AM]
Microsoft ASP.NET QuickStarts Tutorial
Handling Errors
Security Security Overview Authentication & Authorization Windows-based Authentication Forms-based Authentication Authorizing Users and Roles
VB Intro1.aspx
[Run Sample] | [View Source]
User Account Impersonation Security and WebServices
Localization Internationalization Overview Setting Culture and Encoding Localizing ASP.NET Applications Working with Resource Files
Tracing Tracing Overview Trace Logging to Page Output Application-level Trace Logging
Important: Note that nothing happens yet when you click the Lookup button. This is because the .aspx file contains only static HTML (no dynamic content). Thus, the same HTML is sent back to the client on each trip to the page, which results in a loss of the contents of the form fields (the text box and drop-down list) between requests.
Using ASP <% %> Render Blocks ASP.NET provides syntax compatibility with existing ASP pages. This includes support for <% %> code render blocks that can be intermixed with HTML content within an .aspx file. These code blocks execute in a topdown manner at page render time. The below example demonstrates how <% %> render blocks can be used to loop over an HTML block (increasing the font size each time):
Debugging The SDK Debugger
Performance Performance Overview Performance Tuning Tips
VB Intro2.aspx
Measuring Performance
[Run Sample] | [View Source] ASP to ASP.NET Migration Migration Overview Syntax and Semantics Language Compatibility COM Interoperability Transactions
Sample Applications
Important: Unlike with ASP, the code used within the above <% %> blocks is actually compiled--not interpreted using a script engine. This results in improved runtime execution performance. ASP.NET page developers can utilize <% %> code blocks to dynamically modify HTML output much as they can today with ASP. For example, the following sample demonstrates how <% %> code blocks can be used to interpret results posted back from a client.
A Personalized Portal An E-Commerce Storefront A Class Browser Application IBuySpy.com Get URL for this page VB Intro3.aspx
[Run Sample] | [View Source]
http://samples.gotdotnet.com/quickstart/aspplus/doc/webformsintro.aspx (2 of 7) [4/02/2002 8:50:18 AM]
Microsoft ASP.NET QuickStarts Tutorial
Important: While <% %> code blocks provide a powerful way to custom manipulate the text output returned from an ASP.NET page, they do not provide a clean HTML programming model. As the sample above illustrates, developers using only <% %> code blocks must custom manage page state between round trips and custom interpret posted values.
Introduction to ASP.NET Server Controls In addition to (or instead of) using <% %> code blocks to program dynamic content, ASP.NET page developers can use ASP.NET server controls to program Web pages. Server controls are declared within an .aspx file using custom tags or intrinsic HTML tags that contain a runat="server" attribute value. Intrinsic HTML tags are handled by one of the controls in the System.Web.UI.HtmlControls namespace. Any tag that doesn't explicitly map to one of the controls is assigned the type of System.Web.UI.HtmlControls.HtmlGenericControl. The following sample uses four server controls: