다음을 통해 공유


@ Master 

Defines master page–specific (.master file) attributes that are used by the ASP.NET page parser and compiler.

<%@ Master attribute="value" [attribute="value"...] %>

Attributes

Term Definition

AutoEventWireup

Indicates whether simple event handlers can be defined for specific life cycle stages using the syntax Page without any explicit hookup or event signature. true if event auto-wiring is enabled; otherwise, false. The default is true. For more information, see ASP.NET Web Server Control Event Model.

ClassName

Specifies the class name for the class that is automatically generated from the markup and compiled when the master page is processed. This value can be any valid class name and can include a namespace.

CodeFile

Specifies the name of a separate file that contains a partial class with the event handlers and other master page–specific code. For more information, see ASP.NET Web Page Code Model.

CompilationMode

Specifies whether to compile an ASP.NET master page at run time. Options are Always to always compile the page; Auto, if ASP.NET is to avoid compiling the page, if possible; and Never, to never compile the page or control. The default is Always.

CompilerOptions

Provides a string containing compiler options to use to compile the page. In C# and Microsoft Visual Basic, this is a sequence of compiler command-line switches.

Debug

Indicates whether to compile the master page with debug symbols. true, to compile with debug symbols; otherwise, false.

Description

Provides a text description of the master page. This value is ignored by the ASP.NET parser.

EnableTheming

Indicates whether the appearance of the master page and of controls on the master page can be modified, if a theme is applied. true if a theme can be applied; otherwise, false. The default is true. Setting the EnableTheming attribute is primarily useful when a page theme is defined in the Web.config file and applies to all pages, by default. For more information, see ASP.NET Themes and Skins Overview.

EnableViewState

Indicates whether view state is maintained across page requests. true to maintain view state; otherwise, false. The default is true.

Explicit

Determines whether the page is compiled using the Visual Basic Option Explicit mode. true indicates that the Visual Basic explicit compile option is enabled and that all variables must be declared using a Dim, Private, Public, or ReDim statement; otherwise, false. The default is false.

NoteNote

The Explicit attribute is ignored by languages other than Visual Basic.

The Explicit attribute is set to true in the Machine.config file. For more information, see Machine Configuration Files.

Inherits

Specifies a code-behind class for the page to inherit. This can be any class derived from the MasterPage class. For information about code-behind classes, see ASP.NET Page Class Overview.

Language

Specifies the language used when compiling all inline rendering (<% %> and <%= %>) and code declaration blocks within the page. Values can represent any language that is supported by the .NET Framework, including VB (Visual Basic), C#, and JScript.

LinePragmas

Determines whether the runtime should generate pragmas in the generated code.

MasterPageFile

Specifies the .master file that acts as a master page for a master page. The MasterPageFile attribute is used in a master page when defining a child master page in a nested master-page scenario. For details, see Nested ASP.NET Master Pages.

Src

Specifies the source file name of the code-behind class to dynamically compile when the page is requested. You can choose to include programming logic for your page either in a code-behind class or in a Code Declaration Blocks in the .aspx file.

Strict

Specifies whether to compile the page using the Visual Basic Option Strict mode. true if Option Strict is enabled; otherwise, false. The default is false.

NoteNote

The Strict attribute is ignored by languages other than Visual Basic.

WarningLevel

Specifies the compiler warning level at which you want the compiler to abort compilation for the page. Possible values are from 0 through 4. For more information, see WarningLevel.

Remarks

You can use the @ Master directive only in master pages. Master pages are defined in files with the .master extension. You can include only one @ Master directive per .master file.

Example

The following code example demonstrates how to instruct the ASP.NET page compiler to use Visual Basic as the inline code language. The event-handling code is defined in a partial class named MasterPageSample. The code for the MasterPageSample class can be found in the MasterPageSample.master.vb file.

<% @ Master Language="VB" CodeFile="MasterPageSample.master.vb" Inherits="MasterPageSample" %>

See Also

Concepts

ASP.NET Web Page Syntax Overview
ASP.NET Master Pages Overview