Directive Syntax

Specifies settings used by the page and user control compilers when they processes ASP.NET Web Forms page (.aspx) and user control (.ascx) files.

Remarks

When used, directives can be located anywhere in an .aspx or .ascx file, though standard practice is to include them at the beginning of the file. Each directive can contain one or more attributes (paired with values) that are specific to that directive.

Note   The @ Page directive can be used only in .aspx files, while the @ Control directive can be used only in .ascx files.

The Web Forms page framework supports the following directives.

@ Page Defines page-specific attributes used by the ASP.NET page parser and compiler. Can be included only in .aspx files.
@ Control Defines control-specific attributes used by the ASP.NET page parser and compiler. Can be included only in .ascx files (user controls).
@ Import Explicitly imports a namespace into a page or user control.
@ Implements Declaratively indicates that a page or user control implements a specified .NET Framework interface.
@ Register Associates aliases with namespaces and class names, thereby allowing user controls and custom server controls to be rendered when included in a requested page or user control.
@ Assembly Declaratively links an assembly to the current page or user control.
@ OutputCache Declaratively controls the output caching policies of a page or user control.
@ Reference Declaratively links a page or user control to the current page or user control.

ASP.NET treats any directive block (<%@ %>) that does not contain an explicit directive name as an @ Page directive for a page, or an @ Control directive for a user control.

See Also

Page Class | ASP.NET Web Forms Syntax