DOT NET 4.0 – Directives for Web Forms Pages – @ Page Directives

Defines page-specific (.aspx file) attributes used by the ASP.NET page parser and compiler.

<%@ Page attribute="value" [attribute="value"…] %>

Attributes

AspCompat

When set to true, this allows the page to be executed on a single-threaded apartment (STA) thread. This allows the page to call STA components, such as a component developed with Microsoft Visual Basic 6.0. Setting this attribute to true also allows the page to call COM+ 1.0 components that require access to the unmanaged Active Server Pages (ASP) built-in objects. These are accessible through the ObjectContext object or the OnStartPage method. The default is false.

Note Setting this attribute to true can cause your page’s performance to degrade.

AutoEventWireup

Indicates whether the page’s events are autowired. true if event auto wiring is enabled; otherwise, false. The default is true. For more information, see Web Server Control Event Model.

Buffer

Determines if HTTP response buffering is enabled. true if page buffering is enabled; otherwise, false. The default is true.

ClassName

Specifies the class name for the page that will by automatically compiled dynamically when the page is requested. This value can be any valid class name, but should not include a namespace.

ClientTarget

Indicates the target user agent for which ASP.NET server controls should render content. This value can be any valid user agent or alias.

CodePage

Indicates the code page value for the response.

Note If you created your Web Forms page using a code page other than the default code page of the Web server on which the page will run, you must set this attribute. The value you enter should be the code page for the computer on which you created the page. For more information about code pages, search the Microsoft Developers Network (MSDN) at http://msdn.microsoft.com.

CompilerOptions

A string containing compiler options used to compile the page. In C# and Visual Basic .NET, this is a sequence of compiler command line switches.

ContentType

Defines the HTTP content type of the response as a standard MIME type. Supports any valid HTTP content type string. For a list of possible values, visit http://www.microsoft.com/technet and search for MIME.

Culture

Indicates the culture setting for the page. For information about culture settings and possible culture values, see the CultureInfo class.

Debug

Indicates whether the page should be compiled with debug symbols. true if the page should be compiled with debug symbols; otherwise, false.

Description

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

EnableSessionState

Defines session-state requirements for the page. true if session state is enabled; ReadOnly if session state can be read but not changed; otherwise, false. The default is true. These values are case insensitive. For more information, see Session State.

EnableViewState

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

EnableViewStateMac

Indicates that ASP.NET should run a machine authentication check (MAC) on the page’s view state when the page is posted back from the client. true if view state should be MAC checked; otherwise, false. The default is false.

Note A view state MAC is an encrypted version the hidden variable that a page’s view state is persisted to when sent to the browser. When you set this attribute to true, the encrypted view state is checked to verify that it has not been tampered with on the client.

ErrorPage

Defines a target URL for redirection if an unhandled page exception occurs.

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.

Note This attribute is ignored by languages other than Visual Basic .NET. Also, this option is set to true in the machine.config configuration file. For more information, see Machine Configuration Files.

Inherits

Defines a code-behind class for the page to inherit. Can be any class derived from the Page class. For information about code-behind classes, see Web Forms Code Model.

Language

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

LCID

Defines the locale identifier for the Web Forms page.

Note The locale identifier is a 32-bit value that uniquely defines a locale. ASP.NET uses the default locale of the Web server unless you specify a different locale for a Web Forms page by using this attribute. For more information about locales, search MSDN.

ResponseEncoding

Indicates the response encoding of page content. Supports values from the Encoding.GetEncoding method.

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 block in the .aspx file.

Note RAD designers, such as Visual Studio .NET, do not use this attribute. Instead, they precompile code-behind classes and then use the Inherits attribute.

SmartNavigation

Indicates whether the page supports the Internet Explorer 5 or later smart navigation feature.

Note For more information about smart navigation, see the Remarks section.

Strict

Indicates that the page should be compiled using the Visual Basic Option Strict mode. true if option strict is enabled; otherwise, false. The default is false.

Note This attribute is ignored by languages other than Visual Basic .NET.

Trace

Indicates whether tracing is enabled. true if tracing is enabled; otherwise, false. The default is false. For more information, see ASP.NET Trace.

TraceMode

Indicates how traces messages are to be displayed for the page when tracing is enabled. Possible values are SortByTime and SortByCategory. The default, when tracing is enabled, is SortByTime. For more information about tracing, see ASP.NET Trace.

Transaction

Indicates whether transactions are supported on the page. Possible values are Disabled, NotSupported, Supported, Required, and RequiresNew. The default is Disabled.

UICulture

Specifies the UI culture setting to use for the page. Supports any valid UI culture value.

WarningLevel

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

Remarks

This directive can only be used in Web Forms pages. You can only include one @ Page directive per .aspx file. To define multiple attributes for the directive, use a space-separated list (do not include a space on either side of the equals sign of a specific attribute, as in trace="true").

Smart navigation is an ASP.NET feature that is supported in Internet Explorer 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.

Example

The following code instructs the ASP.NET page compiler to use Visual Basic as the inline code language and sets the default HTTP MIME ContentType transmitted to the client to "text/xml".

Reference : Dilip Kumar Jena ( https://mstechexplore.wordpress.com )

 

Advertisements

One thought on “DOT NET 4.0 – Directives for Web Forms Pages – @ Page Directives

  1. I just want to mention I am beginner to blogging and site-building and certainly savored you’re page. Almost certainly I’m planning to bookmark your blog . You actually come with wonderful article content. Cheers for revealing your webpage.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s