Logo

Navigation
  • Home
  • Services
    • ERP Solutions
    • Implementation Solutions
    • Support and Maintenance Solutions
    • Custom Solutions
    • Upgrade Solutions
    • Training and Mentoring
    • Web Solutions
    • Production Support
    • Architecture Designing
    • Independent Validation and Testing Services
    • Infrastructure Management
  • Expertise
    • Microsoft Development Expertise
    • Mobile Development
    • SQL Server Database and BI
    • SAP BI, SAP Hana, SAP BO
    • Oracle and BI
    • Oracle RAC
  • Technical Training
    • Learn Data Management
      • Business Intelligence
      • Data Mining
      • Data Modeling
      • Data Warehousing
      • Disaster Recovery
    • Learn Concepts
      • Application Development
      • Client Server
      • Cloud Computing Tutorials
      • Cluster Computing
      • CRM Tutorial
      • EDI Tutorials
      • ERP Tutorials
      • NLP
      • OOPS
      • Concepts
      • SOA Tutorial
      • Supply Chain
      • Technology Trends
      • UML
      • Virtualization
      • Web 2.0
    • Learn Java
      • JavaScript Tutorial
      • JSP Tutorials
      • J2EE
    • Learn Microsoft
      • MSAS
      • ASP.NET
      • ASP.NET 2.0
      • C Sharp
      • MS Project Training
      • Silverlight
      • SQL Server 2005
      • VB.NET 2005
    • Learn Networking
      • Networking
      • Wireless
    • Learn Oracle
      • Oracle 10g
      • PL/SQL
      • Oracle 11g Tutorials
      • Oracle 9i
      • Oracle Apps
    • Learn Programming
      • Ajax Tutorial
      • C Language
      • C++ Tutorials
      • CSS Tutorial
      • CSS3 Tutorial
      • JavaScript Tutorial
      • jQuery Tutorial
      • MainFrame
      • PHP Tutorial
      • VBScript Tutorial
      • XML Tutorial
    • Learn Software Testing
      • Software Testing Types
      • SQA
      • Testing
  • Career Training
    • Career Improvement
      • Career Articles
      • Certification Articles
      • Conflict Management
      • Core Skills
      • Decision Making
      • Entrepreneurship
      • Goal Setting
      • Life Skills
      • Performance Development
      • Personal Excellence
      • Personality Development
      • Problem Solving
      • Relationship Management
      • Self Confidence
      • Self Supervision
      • Social Networking
      • Strategic Planning
      • Time Management
    • Education Help
      • Career Tracks
      • Essay Writing
      • Internship Tips
      • Online Education
      • Scholarships
      • Student Loans
    • Managerial Skills
      • Business Communication
      • Business Networking
      • Facilitator Skills
      • Managing Change
      • Marketing Management
      • Meeting Management
      • Process Management
      • Project Management
      • Project Management Life Cycle
      • Project Management Process
      • Project Risk Management
      • Relationship Management
      • Task Management
      • Team Building
      • Virtual Team Management
    • Essential Life Skills
      • Anger Management
      • Anxiety Management
      • Attitude Development
      • Coaching and Mentoring
      • Emotional Intelligence
      • Stress Management
      • Positive Thinking
    • Communication Skills
      • Conversation Skills
      • Cross Culture Competence
      • English Vocabulary
      • Listening Skills
      • Public Speaking Skills
      • Questioning Skills
    • Soft Skills
      • Assertive Skills
      • Influence Skills
      • Leadership Skills
      • Memory Skills
      • People Skills
      • Presentation Skills
    • Finding a Job
      • Etiquette Tips
      • Group Discussions
      • HR Interviews
      • Interview Notes
      • Job Search Tips
      • Resume Tips
      • Sample Resumes
 

ASP.NET Page Object Model

By Exforsys | on August 14, 2005 |
ASP.NET 2.0

ASP.NET Page Object Model

In this tutorial you will learn about Page Object Model, the Attributes of the @Page directive, the properties of the Page Class, Methods of the Page Class, Page Class Events and the Page Scripting Object Model.

 

The page class is represented by the .aspx file in ASP.NET 2.0. It provides the basic behaviour for all pages. A class is dynamically created when the .aspx file is parsed and this class inherits from the page class. In ASP.NET 2.0, the page class allows code separation. It invokes the IHTTPHandler interface to service the requests for the page. The page class also inherits from the TemplateControl class and so functions like a control. Since it implements the IPaginationContainer interface the page is paginated by the new Pager control.

The Attributes of the @Page directive

It is interesting to note that the behaviour of each page can be controlled using the attributes of the @Page directive. ASP.NET has not revolutionized the Page class, but it has enhanced it by adding new features to it.

The @Page directive is the point of control for the developer. The new attributes that have been added to this directive are:

1. 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.

2. CompileWeb: This attribute specifies the name of the referenced code-beside file to use for the page.

3. EnablePersonalization: Indicates whether profile information should be used to build the page.

4. MasterPageFile: This attribute specifies the path of the master to use for building the current page.

5. PersonalizationProvider: this attribute specifies a valid provider defined in the application’s configuration file.

6. Theme: specifies the name of the theme to be used.

If Boolean Async directive is used ASP.NET serves up the page in a 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:

1. 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.

2. 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.

3. Master is the attribute that gets the master page and determines the overall look of the page.

4. Pager is an instance of the pager control and it paginates the contents of the current page.

5. 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:

1. EnablePersonalization which sets and gets any profile information required to build the page.

2. EnableTheming which helps configure the page to ignore themes.

3. IsAsync indicates whether a page is processed asynchronously.

4. 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.

5. IsPagePersonalized provides details of profile information for the page and indicates whether this is being currently used.

6. MasterPageFile is used to get or set the file name of the master page for the current page.

7. 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.

8. PersonalizationMode defines the mode of personalization by using a value taken from the enumeration.

9. PreviousPage is used to return the object to the previously visited page object when cross page posting is done.

10. 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.

1. EnsureID provides the current page object with an id.

2. Focus is intended to give the page an input focus.

3. 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.

4. GetValidation returns the collection of all validator controls that belong to a group.

5. GetWebResourceControlState registers the specified control for control state management

6. SetFocus sets the input focus of the control on the page

7. 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:

1. InitComplete is called when the page is initialized and the process is complete.

2. LoadComplete as the name suggests is called at the end of the load stage of the page’s life cycle.

3. PreInit is called before the page is initialized

4. PreLoad is called before the loading of the page is complete.

5. 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.

The new methods, events and properties of the page class have streamlined the developer’s control over the page class. The ASP.NET 2.0 developer is now presented with an environment that makes for rapid application development and provides very good control over the output from the application.

The Page Scripting Object Model

ASP.NET 2.0 allows calls to the server events from client codes without causing the page to post back and refresh. This is done by a kind of remote scripting engine implemented through a call back mechanism. The script callbacks pass the results of the server side method execution directly to a JavaScript function. The JavaScript function then updates the user interface via Dynamic HTML. Additionally the scripting model has been enhanced to set focus on a control by calling the SetFocus method. The ASP.NET 2.0 SetFocus method caches the ID of the control and forces the page class to generate ad hoc script code when the page is rendered. A DefaultFocus property can be set on a form to denote which control should receive immediate focus on page load.

Script callbacks can be used to redraw specific controls and provide the users with different views of the same data. Users can download additional information by auto-filling one or more fields. This is especially useful in the Treeview control. The script callback is initiated when the client side event triggers the JavaScript named WebForm_DoCallback. A link button or a client side button such as an HTML button could be used to trigger the event as the < asp:button > refreshes the whole page. This script requires a few arguments like pageID, argument, returnCallback, context, errorCallback.

In this section of the tutorial we have focused on the Page class, its properties, methods and events. In the next section we shall examine the Server Controls that are offered up by ASP.NET 2.0.

« « ASP.NET Code Directory
Oracle Apps 11i: Setting up Chart Of Accounts (COA) » »

Author Description

Avatar

Editorial Team at Exforsys is a team of IT Consulting and Training team led by Chandra Vennapoosa.

Free Training

RSSSubscribe 385 Followers
  • Popular
  • Recent
  • ASP.NET Server Controls

    August 15, 2005 - 0 Comment
  • ASP.NET Displaying Master-Detail Data on the Same Page

    September 13, 2005 - 0 Comment
  • ASP.NET Using Web Parts and Controls in Web Pages

    August 22, 2005 - 0 Comment
  • ASP.NET Configuring Page-Level Caching

    August 30, 2005 - 0 Comment
  • ASP.NET Working With Master Pages

    August 17, 2005 - 0 Comment
  • Displaying Master-Detail Data on Separate Pages in ASP.NET

    September 16, 2005 - 0 Comment
  • ASP.NET Web Pages and Layout

    August 23, 2005 - 0 Comment
  • ASP.NET Setting Application-Level Caching

    August 30, 2005 - 0 Comment
  • ASP.NET Creating Content for Master Page

    August 17, 2005 - 0 Comment
  • ASP.NET Creating Web Wizards

    September 16, 2005 - 0 Comment
  • Application Development in .NET

    November 21, 2007 - 0 Comment
  • ASP.NET Advanced Site Functionality

    September 16, 2005 - 0 Comment
  • ASP.NET : Dynamic Image control

    September 16, 2005 - 0 Comment
  • ASP.NET Creating Web Wizards

    September 16, 2005 - 0 Comment
  • Displaying Master-Detail Data on Separate Pages in ASP.NET

    September 16, 2005 - 0 Comment
  • ASP.NET Displaying Master-Detail Data on the Same Page

    September 13, 2005 - 0 Comment
  • ASP.NET DataBound Controls – Details View

    September 13, 2005 - 0 Comment
  • ASP.NET Using a Grid to Display Detail Information

    September 13, 2005 - 0 Comment
  • ASP.NET Adding Sorting and Paging in GridView

    September 10, 2005 - 0 Comment
  • ASP.NET GridView Filtering

    September 10, 2005 - 0 Comment

Exforsys e-Newsletter

ebook
 

Related Articles

  • Application Development in .NET
  • ASP.NET Advanced Site Functionality
  • ASP.NET : Dynamic Image control
  • ASP.NET Creating Web Wizards
  • Displaying Master-Detail Data on Separate Pages in ASP.NET

Latest Articles

  • Project Management Techniques
  • Product Development Best Practices
  • Importance of Quality Data Management
  • How to Maximize Quality Assurance
  • Utilizing Effective Quality Assurance Strategies
  • Sitemap
  • Privacy Policy
  • DMCA
  • Trademark Information
  • Contact Us
© 2023. All Rights Reserved.IT Training and Consulting
This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish.AcceptReject Read More
Privacy & Cookies Policy

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Non-necessary
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.
SAVE & ACCEPT