O'Reilly logo

Programming ASP.NET, 3rd Edition by Dan Hurwitz, Jesse Liberty

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

Directives

Directives are used to pass optional settings to the ASP.NET pages and compilers. They typically have the following syntax:

<%@ directive attribute=value [attribute=value] %>

The many valid types of directives will be described in detail in the following sections. Each directive can have one or more attribute/value pairs unless otherwise noted. Attribute/value pairs are separated by a space character . These pairs do not have any space characters surrounding the equals sign (=) between the attribute and its value.

Directives are typically located at the top of the appropriate file though that is not a strict requirement. For example, Application directives are at the top of the global.asax file, and Page directives are at the top of the .aspx files.

Application Directive

The Application directive is used to define application-specific attributes. It is typically the first line in the global.asax file, which is described fully in Chapter 18.

Here is a sample Application directive:

<%@ Application Language="C#" %>

There are three possible attributes for use in the Application directive, which are outlined in Table 6-7.

Table 6-7. Application directive attributes

Attribute

Description

Inherits

The name of the class to inherit from.

Description

Text description of the application. This is ignored by the parser and compiler.

Language

Identifies the language used in any code blocks. Valid values are "C#", "VB", and "JS". As other languages adopt support for the .NET Framework, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required