Team LiB
Previous Section Next Section

ASP.NET Directives

There are many directives that you can use in your Web applications. The directive types include application, assembly, control, implements, import, OutputCache, Page, Reference, and Register . Table 23-1 lists some of the most common ones and on which objects they can be used.

Table 23-1: ASP.NET Directives

Directive

Description

Application

Used to define application-level attributes

Assembly

Links an assembly to the application

Control

Used by controls

Implements

Allows a page to implement a COM interface

Import

Imports a namespace into a page

OutputCache

Used to cache pages, controls, or data

Page

Defines page-specific attributes

Reference

Links another page or control to this page

Register

Associates an alias with a user control

The Page directive is probably the most important, and it has some specific attributes, which are listed in Table 23-2.

Table 23-2: Page Directive Attributes

Attribute

Description

AutoEventWireup

Sets event postbacks

Buffer

Sets up response buffering

ClassName

Sets the page class name

ClientTarget

Targets user agents where controls should be rendered

CodeBehind

Sets the .cs file that runs the code for the page

Debug

Sets compiling with symbols

Description

Provides a description

EnableSessionState

Enables or disables SessionState

EnableViewState

Enables or disables ViewState

Note 

ViewState allows controls on a Web page to maintain their values and state between postbacks. When a button is clicked and it results in a round-trip from the client to server, the value of the controls with ViewState enabled will be maintained.


Team LiB
Previous Section Next Section