📅  最后修改于: 2020-11-21 05:44:20             🧑  作者: Mango
ASP.NET指令是用于指定可选设置的指令,例如注册自定义控件和页面语言。这些设置描述了.Net框架如何处理Web表单(.aspx)或用户控件(.ascx)页面。
声明指令的语法为:
在本节中,我们将仅介绍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. |
Implement指令指示网页,母版页或用户控制页必须实现指定的.Net Framework接口。
Implements指令的基本语法为:
Import指令将名称空间导入到应用程序的网页,用户控制页中。如果在global.asax文件中指定了Import指令,则它将应用于整个应用程序。如果它位于用户控件页面的页面中,则将其应用于该页面或控件。
import指令的基本语法为:
Master指令将页面文件指定为母页面。
示例MasterPage指令的基本语法为:
MasterType指令将一个类名称分配给页面的Master属性,以使其具有强类型。
MasterType指令的基本语法为:
OutputCache指令控制网页或用户控件的输出缓存策略。
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指令的基本语法为:
Reference指令指示应编译另一个页面或用户控件并将其链接到当前页面。
Reference指令的基本语法为:
Register派生用于注册自定义服务器控件和用户控件。
Register指令的基本语法为: