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] %>
There are many valid types of directives, which 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. Be careful not to have any space characters surrounding the equal sign (=) between the attribute and its value.
Directives are typically located at the top of the appropriate file,
although 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 20.
Here is a sample Application directive:
<%@ Application Language="C#" Codebehind="Global.asax.cs"\
Inherits="WebApplication1.Global" %>There are four possible
attributes
for use in the Application directive, which are
outlined in Table 6-5.
Table 6-5. Possible attributes for the Application directive
|
Attribute |
Description |
|---|---|
|
|
Used by Visual Studio .NET to identify a code-behind file. |
|
|
The name of the class to inherit from. |
|
|
Text description of the application. This is ignored by the ... |
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access