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. 8.6.1. Application DirectiveThe Application directive is used to define application-specific attributes . It is typically the first line in the global.asax file. Here is a sample Application directive: <%@ Application Language="VB" %> There are three possible attributes for use in the Application directive, which are outlined in Table 8-4.
IntelliSense will help you with choosing the enumerated value, as shown in Figure 8-34. Figure 8-34. Setting the Application Language directive8.6.2. Assembly DirectiveThe Assembly directive links an assembly to the application or page at parse time. It is analogous to the /reference: command-line switch used by the VB.NET command-line compilers. The Assembly directive is contained in either the global.asax file, for application-wide linking, or in a page (.aspx) or user control (.ascx) file, for linking to a specific page or user control. There can be multiple Assembly directives in any file. Each Assembly directive can have multiple attribute/value pairs. Assemblies located in the \bin subdirectory under the application's virtual root are automatically linked to the application and do not need to be included in an Assembly directive. There are two permissible attributes, listed in Table 8-5 and shown in Figure 8-35.
Figure 8-35. Setting the Assembly directiveOther directives will be covered later in the book as their use becomes relevant. |