asp.net.ph

Skip Navigation LinksHome > Getting Started > ASP.NET Syntax > ASP.NET Page Syntax > Page Directives Syntax

Page Directives Syntax

ASP.NET Syntax   ASP.NET Page Syntax


Specifies settings used by the page and user control compilers when processing 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.

The Web Forms Page Framework supports the following directives.

@ Assembly Declaratively links an assembly to the current page or user control.
@ Control Defines control-specific attributes used by the ASP.NET page parser and compiler. Can only be included in .ascx files ( user controls ).
@ Implements Declaratively indicates that a page or user control implements a specified .NET Framework interface.
@ Import Explicitly imports a namespace into a page or user control.
@ Master Identifies an ASP.NET master page.
@ MasterType Assigns a class name to the Master property of an ASP.NET page, so that the page can get strongly typed references to members of the master page.
@ OutputCache Declaratively controls the output caching policies of a page or user control.
@ Page Defines page-specific attributes used by the ASP.NET page parser and compiler. Can only be included in .aspx files.
@ PreviousPageType Provides the means to get strong typing against the previous page as accessed through the PreviousPage property.
@ 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.
@ Reference Declaratively links a page or user control to the current page or user control.
<%@ Page language="C#" masterpagefile="~/shared/site.master" title="asp.net.ph : ASP.NET Web WorkShop" 
   Culture="auto:en-US" UICulture="auto:en-US" %>
   
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.IO" %>

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

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



© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note