Getting Started
  Introduction
  What is ASP.NET?
  Language Support

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
  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

Working with Server Controls


This section of the QuickStart illustrates some common core concepts and common actions performed by end users when using ASP.NET server controls within a page.

Declaring Server Controls

ASP.NET server controls are identified within a page using declarative tags that contain a runat="server" attribute. The following example declares three <asp:label runat="server"> server controls and customizes the text and style properties of each one individually.

 
VB Controls1.aspx

[Run Sample] | [View Source]


Manipulating Server Controls

You can programmatically identify an individual ASP.NET server control within a page by providing it with an id attribute. You can use this id reference to programmatically manipulate the server control's object model at run time. For example, the following sample demonstrates how a page developer could programmatically set an <asp:label runat="server"> control's Text property within the Page_Load event.

 
VB Controls2.aspx

[Run Sample] | [View Source]


Handling Control Action Events

ASP.NET server controls can optionally expose and raise server events, which can be handled by page developers. A page developer may accomplish this by declaratively wiring an event to a control (where the attribute name of an event wireup indicates the event name and the attribute value indicates the name of a method to call). For example, the following code example demonstrates how to wire an OnClick event to a button control.

 
VB Controls3.aspx

[Run Sample] | [View Source]


Handling Multiple Control Action Events

Event handlers provide a clean way for page developers to structure logic within an ASP.NET page. For example, the following sample demonstrates how to wire and handle four button events on a single page.

 
VB Controls4.aspx

[Run Sample] | [View Source]


Performing Page Navigation (Scenario 1)

Page navigation among multiple pages is a common scenario in virtually all Web applications. The following sample demonstrates how to use the <asp:hyperlink runat=server> control to navigate to another page (passing custom query string parameters along the way). The sample then demonstrates how to easily get access to these query string parameters from the target page.

 
VB Controls5.aspx

[Run Sample] | [View Source]


Performing Page Navigation (Scenario 2)

Not all page navigation scenarios are initiated through hyperlinks on the client. Client-side page redirects or navigations can also be initiated from the server by an ASP.NET page developer by calling the Response.Redirect(url) method. This is typically done when server-side validation is required on some client input before the navigation actually takes place.

The following sample demonstrates how to use the Response.Redirect method to pass parameters to another target page. It also demonstrates how to easily get access to these parameters from the target page.

 
VB Controls6.aspx

[Run Sample] | [View Source]


Copyright 2001 Microsoft Corporation. All rights reserved.