Page Directives – ASP.NET

Directives specify settings that are used by the page and user-control compilers when the compilers process ASP.NET Web Forms pages (.aspx files) and user control (.ascx) files.

<%@[Directive][Attributes]%>

@Page

@Page Directive is used to specify the attributes for an ASP.NET page file for page parser and the compiler.

<%@ Page Language=“C#”  MasterPageFile=“~/MQSMasterViewDlg.master”  Inherits=“mqsubscribe.PriceCalculatorPage”  CodeFile=“PriceCalculator.aspx.cs” AutoEventWireup=”false”  EnableViewState=”true”  Debug=”true”  TraceMode=”Default”
ErrorPage=”Error.aspx”  Trace=”true”
%>

@Page attributes

  • Language : The programming language for the code to be added.
  • MasterPageFile :The Master file name for the page.
  • Inherits : The name of the code behind or other class.
  • CodeFile :The code behind file name.
  • AutoEventWireup :The Boolean value that enables or disables page events that are being automatically bound to methods; for example, Page_Load.
  • EnableViewState : The Boolean value that enables or disables view state across page requests.
  • Debug : The Boolean value that enables or disables compilation with debug symbols.
  • TraceMode : It indicates how trace messages are displayed, and sorted by time or category.
  • ErrorPage : URL for redirection if an unhandled page exception occurs.
  • Trace : It enables or disables tracing.

@Master

@Master specifies a page file as being the mater page.

<%@  Master Language=”C#”  Inherits=”mqsubscribe.MQSMasterPage”  CodeFile=”MQSMasterPage.master.cs” EnableTheming=”true”  Explicit=”true” Strict=”true” %>

@Page attributes

  • EnableTheming : Controlls the look of the master page and controls of the master page.
  • Explicit :The page is compiled using the Option Explicit mode. The value true states that the compile is enabled.
  • Strict : The page is compiled using the Option Strict mode.

Leave a Reply

Your email address will not be published. Required fields are marked *