Page Directives in Asp.Net
The directives are instructions that specify optional settings in Asp.Net, but they are not rendered as part of the HTML page return to the client browser. These instructions include registering a custom control, page language etc. It describes how the .aspx pages (web forms) or .ascx pages (user controls) are processed by the .Net framework.
The most commonly used directive is the @ Page directive and it can be used only in Web Forms. Page directive allows you to specify many configuration options for the page. By default, Visual Studio creates a page directive as shown below:
You can include only one @ Page directive in your .aspx file. Also you should specify one language in the Language attribute. This can be any .NET Framework-supported language, including VB.Net, C#, or JScript.
AutoEventWireup controlled the automatic binding of page events based on the method naming convention. The default is true, which performs the automatic lookup and binding. If it is set to False then you should create methods with any name and bind them to page events explicitly
CodeFile specifies a path to the referenced code-behind file for the page. Inherits defines the name of the class from which to inherit. This can be any class derived from the Page class
Different types of directives in Asp.Net
The @Assembly Directive attaches assemblies to the page or an ASP.NET user control thereby all the assembly classes and interfaces are available to the class. This directive supports the two attributes Name and src. The Name attribute defines the assembly name and the src attribute defines the source of the assembly.
Defines control-specific attributes used by the ASP.NET page parser and compiler and can be included only in .ascx files (user controls).
The @Implements Directive gets the ASP.NET pages to implement .Net framework interfaces. This directive only supports a single attribute interface.
The Import directive imports a namespace into a web page, user control page of application. If the Import directive is specified in the global.asax file, then it is applied to the entire application. If it is in a page of user control page, then it is applied to that page or control.
Identifies a page as a master page and defines attributes used by the ASP.NET page parser and compiler and can be included only in .master files.
Defines the class or virtual path used to type the Master property of a page.
The OutputCache directive controls the output caching policies of a web page or a user control.
The @Page directive enables you to specify attributes and values for an Asp.Net Page to be used when the page is parsed and compiled. Every .aspx files should include this @Page directive to execute. There are many attributes belong to this directive.
Creates a strongly typed reference to the source page from the target of a cross-page posting.
Links a page, user control, or COM control to the current page or user control declaratively.
Associates aliases with namespaces and classes, which allow user controls and custom server controls to be rendered when included in a requested page or user control.