Online Book Reader

Home Category

Programming Microsoft ASP.NET 4 - Dino Esposito [96]

By Root 5265 0

TraceMode

Indicates how trace messages are to be displayed for the page when tracing is enabled. Feasible values are SortByTime and SortByCategory. The default, when tracing is enabled, is SortByTime.

WarningLevel

Indicates the compiler warning level at which you want the compiler to abort compilation for the page. Possible values are 0 through 4.

Attributes listed in Table 5-5 allow you to control to some extent the overall behavior of the page and the supported range of features. For example, you can set a custom error page, disable session state, and control the transactional behavior of the page.

Note

The schema of attributes supported by @Page is not as strict as for other directives. In particular, any public properties defined on the page class can be listed as an attribute, and initialized, in a @Page directive.

Table 5-5. @Page Attributes for Page Behavior

Attribute

Description

AspCompat

A Boolean attribute that, when set to true, allows the page to be executed on a single-threaded apartment (STA) thread. The setting allows the page to call COM+ 1.0 components and components developed with Microsoft Visual Basic 6.0 that require access to the unmanaged ASP built-in objects. (I’ll return to this topic in Chapter 16.)

Async

If this attribute is set to true, the generated page class derives from IHttpAsyncHandler rather than having IHttpHandler add some built-in asynchronous capabilities to the page.

AsyncTimeOut

Defines the timeout in seconds used when processing asynchronous tasks. The default is 45 seconds.

AutoEventWireup

A Boolean attribute that indicates whether page events are automatically enabled. It’s set to true by default. Pages developed with Visual Studio .NET have this attribute set to false, and page events for these pages are individually tied to handlers.

Buffer

A Boolean attribute that determines whether HTTP response buffering is enabled. It’s set to true by default.

Description

Provides a text description of the page. The ASP.NET page parser ignores the attribute, which subsequently has only a documentation purpose.

EnableEventValidation

A Boolean value that indicates whether the page will emit a hidden field to cache available values for input fields that support event data validation. It’s set to true by default.

EnableSessionState

Defines how the page should treat session data. If this attribute is set to true, the session state can be read and written to. If it’s set to false, session data is not available to the application. Finally, if this attribute is set to ReadOnly, the session state can be read but not changed.

EnableViewState

A Boolean value that indicates whether the page view state is maintained across page requests. The view state is the page call context—a collection of values that retain the state of the page and are carried back and forth. View state is enabled by default. (I’ll cover this topic in Chapter 17.)

EnableTheming

A Boolean value that indicates whether the page will support themes for embedded controls. It’s set to true by default.

EnableViewStateMac

A Boolean value that indicates ASP.NET should calculate a machine-specific authentication code and append it to the view state of the page (in addition to Base64 encoding). The Mac in the attribute name stands for machine authentication check. When the attribute is true, upon postbacks ASP.NET will check the authentication code of the view state to make sure that it hasn’t been tampered with on the client.

ErrorPage

Defines the target URL to which users will be automatically redirected in case of unhandled page exceptions.

MaintainScrollPositionOnPostback

A Boolean value that indicates whether to return the user to the same position in the client browser after postback.

SmartNavigation

A Boolean value that indicates whether the page supports the Microsoft Internet Explorer 5 or later smart navigation feature. Smart navigation allows a page to be refreshed without losing scroll position and element focus.

Theme, StylesheetTheme

Indicates the

Return Main Page Previous Page Next Page

®Online Book Reader