New Features in ASP.NET 2.0 Page Model
Dflying | 13 March, 2006 01:40The Attributes of the @Page directive
The @Page directive is the point of control for the developer with some new attributes that have been added to this directive:
- Async: If this is set to true, the page class that is generated derives from IHttpAsyncHandler. It adds some built in asynchronous capabilities to the page.
- CompileWeb: This attribute specifies the name of the referenced code-beside file to use for the page.
- EnablePersonalization: Indicates whether profile information should be used to build the page.
- MasterPageFile: This attribute specifies the path of the master to use for building the current page.
- PersonalizationProvider: this attribute specifies a valid provider defined in the application’s configuration file.
- Theme: specifies the name of the theme to be used.
If Boolean Async directive is used ASP.NET serves up the page in an asynchronous way. The page executes the custom code asynchronously while runtime progresses on the page life cycle. The request threads are synchronized and the output is generated in the browser by setting a single unwind point on the page between PreRender and PreRenderComplete events.
The Properties of the Page Class
The page object has two kinds of properties--the intrinsic objects and the page specific properties. Environmental stand alone objects such as cache, User, Trace and HTTP objects such as Session, Application, Request etc fall within the Intrinsic object properties of the page class. Page specific properties would include IsPostBack, EnableViewState, and SmartNavigation.
Some new properties that have been added to the intrinsic objects are:
- ClientScript is an instance of the ClientScriptManager class. It represents a separate object that groups all the methods that work with the client-side scripts. It returns the manager object of all methods that inject JavaScript code in the page. The RegisterHiddenField and RegisterStartupScript are some of the methods returned. These script related methods have been marked as obsolete in ASP.NET 2.0 and are implemented through a call to the corresponding methods of the ClientScript object.
- The Header is an instance of HtmlHead class and represents the contents of the page’s < head > block if it is marked as runat=server.
- Master is the attribute that gets the master page and determines the overall look of the page.
- Pager is an instance of the pager control and it paginates the contents of the current page.
- SiteCounters is an instance of the SiteCounters class and it represents the built in service to trackpage usage within the application.
The other new properties of the Page class include:
- EnablePersonalization which sets and gets any profile information required to build the page.
- EnableTheming which helps configure the page to ignore themes.
- IsAsync indicates whether a page is processed asynchronously.
- IsCrossPagePostBack indicates whether the page is being loaded in response to a client postback requested by a different page. ASP.NET 2.0 pages no longer has the need to post to themselves. The unique HTML form contents of the pages can be automatically posted to other pages. Using the IsPostBack and IsCrossPostBack properties the pages distinguish between the page and the cross-page postback. In the latter case the values are retrieved from the original controls and the reference to the posting page is returned by the PreviousPage.
- IsPagePersonalized provides details of profile information for the page and indicates whether this is being currently used.
- MasterPageFile is used to get or set the file name of the master page for the current page.
- MaximumWeight is used to get or set the maximum size of each page of content when the pager control is used to paginate the .aspx page.
- PersonalizationMode defines the mode of personalization by using a value taken from the enumeration.
- PreviousPage is used to return the object to the previously visited page object when cross page posting is done.
- Title is used to get and set the string that represents the title of the page.
Methods of the Page Class:
A few new methods have been added to the page class. Most of them have been inherited from the Control class.
- EnsureID provides the current page object with an id.
- Focus is intended to give the page an input focus.
- GetCallbackEventReference returns the prototype of a client side JavaScript function that posts back to the server using a callback function to implement a form of remote scripting.
- GetValidation returns the collection of all validator controls that belong to a group.
- GetWebResourceControlState registers the specified control for control state management
- SetFocus sets the input focus of the control on the page
- TestDeviceFilter checks whether the current browser is of the specified type.
Page Class Events
Events are written by developers to dynamically modify the page output and the controls on the page. ASP.NET helps developers by defining a number of new events so that developers can follow the request processing closely.
The new events added to the page class are:
- InitComplete is called when the page is initialized and the process is complete.
- LoadComplete as the name suggests is called at the end of the load stage of the page’s life cycle.
- PreInit is called before the page is initialized
- PreLoad is called before the loading of the page is complete.
- PreRenderComplete is called when the prerendering phase is complete and all the child controls have been created. After the event, the personalization data and the view state are saved and the page is rendered to HTML.
Posted in
ASP.net.
Comment: (0).
Trackbacks:(90).
Permalink
«Next post |
Previous post»




