Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
ASP .NET 2.0 Beta Preview - B. Evjen.pdf
Скачиваний:
26
Добавлен:
24.05.2014
Размер:
15.33 Mб
Скачать

Application and Page Frameworks

page. In this case, the value assigned is Default.aspx.vb or Default.aspx.cs. The second attribute needed is the ClassName attribute. This attribute was available in previous versions of ASP.NET, but was little used. This attribute specifies the name of the class that is bound to the page when the page is compiled. The directives are simple enough in ASP.NET 2.0. Take a look at the code-behind page from Listing 3-5.

The code-behind page is rather simple in appearance now using the partial class capabilities that .NET 2.0 provides. You can see that the class created in the code-behind file uses partial classes, employing the new Partial keyword in Visual Basic 8.0 and the partial keyword from C#. This enables you to simply place the methods that you need in your page class. In this case, you have a button-click event and nothing else.

New Page Directives

ASP.NET directives are something that is a part of every ASP.NET page. You can control the behavior of your ASP.NET pages by using these directives. Here’s an example of the Page directive:

<%@ Page Language=”VB” AutoEventWireup=”false” CompileWith=”Default.aspx.vb” ClassName=”Default_aspx” %>

New attributes

These page directives are commands for the compiler to use as the page is compiled. A large number of attributes have always been available to the Page directive itself, but with the introduction of ASP.NET 2.0, some additional attributes are available. These six important new attributes are explained in the following table.

New Attribute

Description

 

 

CompileWith

Takes a String value which points to the code-behind

 

file used.

EnablePersonalization

Boolean value that specifies whether the new ASP.NET

 

2.0 personalization features are used with the page.

LinePragmas

Boolean value that specifies whether line pragmas are

 

used with the resulting assembly.

Master

Takes a String value that points to the location of the

 

master page used with the page. This attribute is used

 

with content pages.

PersonalizationProvider

Takes a String value that specifies the name of the per-

 

sonalization provider used in applying personalization

 

to the page.

Theme

String value that specifies the theme used with the page.

 

 

51

Chapter 3

New directives

In addition to the new attributes used with the Page directive, two new directives can be also be used for the pages you create. These new directives include the following:

Master: This directive is used in the creation of master pages — the main templates used by any subpages within your applications. Master pages are explained in Chapter 6.

PreviousPage: This directive is used to specify the page from which any cross-postings originate. Cross-posting ASP.NET pages are explained later in this chapter.

The Master page directive is similar to the Page directive, but you specify properties of the templated page that you will be using in conjunction with any number of content pages in your site. Any content pages (built using the Page directive) you might have can then inherit from the master page all the master content (defined in the master page using the Master directive). Although they are similar, the Master directive has fewer attributes available to it than the Page directive. The available attributes for the Master directive include:

 

AutoEventWireUp

 

Explicit

 

ClassName

 

Inherits

 

CodeBehind

 

Language

 

CompilerOptions

 

LinePragmas

 

CompileWith

 

Master

 

Debug

 

Src

 

Description

 

Strict

 

EnablePersonalization

 

Theme

EnableViewState

These attributes need not be defined because they are the same as those for the Page directive, except that they apply to the master page that is used in templating your pages.

The PreviousPage directive is a new directive that works with the new cross-page posting capability that ASP.NET 2.0 provides. This simple directive contains only two possible attributes: TypeName and VirtualPath. The following table describes these two new attributes.

New Attribute

Description

 

 

TypeName

Specifies the strong type used in the previous page.

VirtualPath

String value specifying the relative path of the page that is

 

cross-posting to the working page.

 

 

52