Asp.net-directives
ASP.NET-ディレクティブ
ASP.NETディレクティブは、カスタムコントロールやページ言語の登録など、オプションの設定を指定するための指示です。 これらの設定は、Webフォーム(.aspx)またはユーザーコントロール(.ascx)ページが.Netフレームワークによってどのように処理されるかを説明します。
ディレクティブを宣言するための構文は次のとおりです。
このセクションでは、ASP.NETディレクティブを紹介し、チュートリアル全体でこれらのディレクティブのほとんどを使用します。
アプリケーションディレクティブ
Applicationディレクティブは、アプリケーション固有の属性を定義します。 global.aspxファイルの上部にあります。
Applicationディレクティブの基本的な構文は次のとおりです。
Applicationディレクティブの属性は次のとおりです。
Attributes | Description |
---|---|
Inherits | The name of the class from which to inherit. |
Description | The text description of the application. Parsers and compilers ignore this. |
Language | The language used in code blocks. |
アセンブリ指令
Assemblyディレクティブは、解析時にアセンブリをページまたはアプリケーションにリンクします。 これは、アプリケーション全体をリンクするglobal.asaxファイル、ページファイル、ページまたはユーザーコントロールにリンクするためのユーザーコントロールファイルのいずれかに表示されます。
Assemblyディレクティブの基本的な構文は次のとおりです。
Assemblyディレクティブの属性は次のとおりです。
Attributes | Description |
---|---|
Name | The name of the assembly to be linked. |
Src | The path to the source file to be linked and compiled dynamically. |
制御指令
制御ディレクティブはユーザーコントロールで使用され、ユーザーコントロール(.ascx)ファイルに表示されます。
Controlディレクティブの基本的な構文は次のとおりです。
Controlディレクティブの属性は次のとおりです。
Attributes | Description |
---|---|
AutoEventWireup | The Boolean value that enables or disables automatic association of events to handlers. |
ClassName | The file name for the control. |
Debug | The Boolean value that enables or disables compiling with debug symbols. |
Description | The text description of the control page, ignored by compiler. |
EnableViewState | The Boolean value that indicates whether view state is maintained across page requests. |
Explicit | For VB language, tells the compiler to use option explicit mode. |
Inherits | The class from which the control page inherits. |
Language | The language for code and script. |
Src | The filename for the code-behind class. |
Strict | For VB language, tells the compiler to use the option strict mode. |
Implementsディレクティブ
Implementディレクティブは、Webページ、マスターページ、またはユーザーコントロールページが指定された.Netフレームワークインターフェイスを実装する必要があることを示します。
implementsディレクティブの基本的な構文は次のとおりです。
インポート指令
Importディレクティブは、名前空間をWebページ、アプリケーションのユーザーコントロールページにインポートします。 import。ディレクティブがglobal.asaxファイルで指定されている場合、アプリケーション全体に適用されます。 ユーザーコントロールページのページにある場合は、そのページまたはコントロールに適用されます。
importディレクティブの基本的な構文は次のとおりです。
マスター指令
マスターディレクティブは、ページファイルをマスターページとして指定します。
サンプルMasterPageディレクティブの基本構文は次のとおりです。
MasterTypeディレクティブ
MasterTypeディレクティブは、クラス名をページのMasterプロパティに割り当てて、強く型付けされます。
MasterTypeディレクティブの基本的な構文は次のとおりです。
OutputCacheディレクティブ
OutputCacheディレクティブは、Webページまたはユーザーコントロールの出力キャッシュポリシーを制御します。
OutputCacheディレクティブの基本的な構文は次のとおりです。
ページディレクティブ
Pageディレクティブは、ページパーサーとコンパイラのページファイルに固有の属性を定義します。
Pageディレクティブの基本的な構文は次のとおりです。
Pageディレクティブの属性は次のとおりです。
Attributes | Description |
---|---|
AutoEventWireup | The Boolean value that enables or disables page events that are being automatically bound to methods; for example, Page_Load. |
Buffer | The Boolean value that enables or disables HTTP response buffering. |
ClassName | The class name for the page. |
ClientTarget | The browser for which the server controls should render content. |
CodeFile | The name of the code behind file. |
Debug | The Boolean value that enables or disables compilation with debug symbols. |
Description | The text description of the page, ignored by the parser. |
EnableSessionState | It enables, disables, or makes session state read-only. |
EnableViewState | The Boolean value that enables or disables view state across page requests. |
ErrorPage | URL for redirection if an unhandled page exception occurs. |
Inherits | The name of the code behind or other class. |
Language | The programming language for code. |
Src | The file name of the code behind class. |
Trace | It enables or disables tracing. |
TraceMode | It indicates how trace messages are displayed, and sorted by time or category. |
Transaction | It indicates if transactions are supported. |
ValidateRequest | The Boolean value that indicates whether all input data is validated against a hardcoded list of values. |
PreviousPageTypeディレクティブ
PreviousPageTypeディレクティブはページにクラスを割り当て、ページが強く型付けされるようにします。
サンプルのPreviousPagetypeディレクティブの基本的な構文は次のとおりです。
参照ディレクティブ
Referenceディレクティブは、別のページまたはユーザーコントロールをコンパイルし、現在のページにリンクする必要があることを示します。
Referenceディレクティブの基本的な構文は次のとおりです。
登録指令
Register派生物は、カスタムサーバーコントロールとユーザーコントロールを登録するために使用されます。
Registerディレクティブの基本的な構文は次のとおりです。