RemarksThis directive can be used only in Web Forms pages. You can include only one
@ Page directive per .aspx file. Further, you can define only one
Language attribute per
@ Page directive, because only one language can be used per page. Because the most commonly used default values are supplied for most of the attributes, either in the source code or in configuration files, it is often unnecessary to add a large set of attributes to the directive. Generally, you should add the minimal set of attributes required to specify the features you want for a page. If there is a common attribute that you want to apply to all pages, for example if you want to enable tracing on all pages, consider enabling the feature in the Web.config file rather than adding the
Trace attribute to every individual page.
Note |
---|
The @ Page directive has a number of attributes in common with other directives that apply to an entire source file, such as the @ Control [ http://msdn.microsoft.com/en-us/library/d19c0t4b(VS.80).aspx ] directive (used in .ascx files for Web user controls) and the @ Master [ http://msdn.microsoft.com/en-us/library/ms228176(VS.80).aspx ] directive (used in .master files for master pages). |
To define multiple attributes for the @ Page directive, separate each attribute/value pair with a single space. For a specific attribute, do not include a space on either side of the equal sign (=) that connects the attribute with its value. For an example, see the Example section of this topic.
Smart navigation is an ASP.NET feature supported in Internet Explorer 5.5 and later browsers. It allows a page to be refreshed while maintaining scroll position and element focus between navigations, causing only a single page to be stored in the browser's history, and without the common flicker associated with refreshing a Web page. Smart navigation is best used with ASP.NET pages that require frequent postbacks but with visual content that does not change dramatically on return. Consider this carefully when deciding whether to set this attribute to true.
When the AspCompat attribute is set to true for a page, if you use a constructor to create a COM component before the request is scheduled, it will run on a multithreaded apartment (MTA) thread. Doing this causes significant Web server performance degradation. To avoid this problem, create COM components only from within one of the Page events (such as Page_Load, Page_Init, and so on) or one of the Page methods. Be sure as well that the objects are not created at page construction time.
The following code example demonstrates the recommended way to create an instance of a COM object in a page with AspCompat enabled.
C#
<%@ Page AspCompat="true" language="C#" %>
<script runat="server" >
MyComObject comObj;
public void Page_Load(){
// Use comObj here when the code is running on the STA thread pool.
comObj = New MyComObject();
// Do something with the combObj object.
}
<%@ Page AspCompat="true" language="VB" %>
<script runat="server" >
Dim comObj As MyComObject
Public Sub Page_Load()
'Use comObj here when the code is running on the STA thread pool.
comObj = New MyComObject()
' Do something with the combObj object.
End Sub
</script>
Note |
---|
Adding an @ Master directive to a master page does not allow you to use the same directive declaration in pages that depend on the master. Instead, use the < pages> element [ http://msdn.microsoft.com/en-us/library/950xf363(VS.80).aspx ] to define page directives globally. |
No comments:
Post a Comment