|
The steps involved in the implementation of the page descriptor, as well as the source content, are described below.
Change the extension of the html page to active page extension
The initial UI would be prepared as html or xhtml page. The page content source location (directory) and name would be reflected in the page-id, whereas the implementation page URL would be entered into the page-url entry in the page descriptor. For pages to be recognized as active content, within ASP.NET, they must have the .aspx extension.
| This: | /pages/northStorm.html |
| becomes: | /pages/northStorm.aspx |
This is captured in the descriptor as shown below
PAGE DESCRIPTOR |
id |
pages/northStorm.html |
page-url |
pages/northStorm.aspx |
template |
|
description |
|
For the implementation, the source content would be copied to the implementation directory and the extension changed from the html or xhtml to the .aspx.
Because of the facilities that the IDE provides, it is sometimes more practical to create a new page using the IDE. With this, the declarations and the code behind would be created automatically. (More on the code behind later.) The code within the source content could then be copied to the page created using the IDE.
Insertion of declaration and other necessary code segments
With the source content in the aspx page, some declarations need to be added to the page.
A minimum declaration entry could appear as shown below.
<%@ page language="C#" CodeFile="CodeBehind_cs_aspx.cs" Inherits="_Default" %>
These entries mainly capture the code behind classes as well as the language in use; there would be need to create the matching code behind class. As mentioned earlier, the declarations and the code behind class is created automatically, if the IDE is use to create the page.
The description of the declaration used in the example above is described below.
| ClassName |
A string that specifies the name of the page class that will be dynamically compiled when the page is requested. If a value for this attribute is not specified, the class name is simply based on the page's file name, using the default namespace.
|
| CodeFile
| Specifies a path to the code-behind file associated with the page. This attribute is used together with the Inherits attribute to associate a code-behind source file with a Web page.
|
| Inherits |
Defines a code-behind class for the page to inherit. This can be any class derived from the Page class.
|
| Language |
Specifies the language used when compiling all inline rendering (<% %> and <%= %>) and code declaration blocks within the page. Although any .NET Framework-supported language could be used, all examples and code samples in this dictionary are based on C#. |
The next page attribute involves the dWebSpec page descriptor template attribute. This is discussed in the next section.
| MasterPageFile |
Sets the path to the master page or template for the content page. |
The next page attribute pertains to event handlers; this is discussed in the event descriptor section.
| AutoEventWireup |
Indicates whether the page's events are autowired. true This refer to the scheme in which the name of an event handler is implicitly derived for the ID of the component, and the event type. This is discussed in the event descriptor section. |
Two other important page attributes are listed below.
| EnableViewState |
Indicates whether the view state of the page is maintained across page requests. The default is true. |
| ErrorPage |
Designates a target URL for redirection, whenever an unhandled page exception occurs. |
Template
The template attribute corresponds to the ASP.NET master page which facilitates a consistent look and behavior for all pages on a site. Whenever a page uses a template (master page) it would obtain its theme and style from such template. The master page provides place holders for which the client page would replace such placeholder (content holder) with content, in form of concrete segment (segment with matching segment id).
Example specification is shown below.
PAGE DESCRIPTOR |
id |
pages/northStorm.html |
page-url |
pages/northStorm.aspx |
template |
northStorm.master |
description |
Design master |
The primary implementation of this involves the declaration on top of the page.
<%@ MasterPageFile="northStorm.master" %>
The segments in the page that matches the template declared content holders segment id, would replace the content of the template. For the full information on templates and the clients that use them, refer to the segment type attribute.
|