ASP .Net Page Directives and Order of Events Execution

by top54u.com 02 Nov, 2007

 

To direct the ASP .Net compiler about the page layout and execution strategy to prepare a page some Page Directives are used as page declaration.
ASP.Net compiler follows these directives. Commonly used page directives are:

  • @Page

  • @Import

  • @Implements

  • @Register

  • @OutputCache

  • @Assembly

You can place these directives anywhere in the .aspx page but typically these are placed at the top of page.

  1. @Page: This directive is used to declare the language attribute such as VB or C# to direct the compiler about the server scripting language.
    For example:
    <%@ Page Language="VB" Debug="true" %>

  2. @Import: This directive is used to import a namespace in a web page.
    For example: To import the namespace of File Input Output
    <%@ Import Namespace="System.IO" %>

  3. @Implements: You can use this directive to implement the interface in a web page.
    For example:
    <%@ Implements Interface="System.Web.UI.ICallbackEventHandler" %>

  4. @Register: This directive can be used to register any custom user control in asp .net web page.
    For example:
    <%@ Register Src="WebUserControl.ascx" TagName="WebUserControl" TagPrefix="uc1" %>

  5. @OutputCache: You can use this directive to specify the time duration to store the output in memory. VaryByParam is a mandatory attribute to specify whether to store variables separately or in the same cache entries. It takes value as "none" or "*". "none" is used to specify separate cache entries and "*" is used to specify no separate cache entry required.
    For example:
    <%@ OutputCache Duration="60" VaryByParam="none" %>

  6. @Assembly: You can use this directive to link the user control or asp .net web page with any assembly.
    For example:
    <%@ Assembly Name="top54u" %>


Order of ASP.NET Web Page Events Execution

When a web page is loaded, reloaded or submitted for postback a sequence of events is followed. Following is the order of execution of events when the page is loaded:

  • Page_Init

  • Page_Load

  • Change events

  • Action events

  • Page_Unload

Page_Init event fires only first time the page is loaded. During postback page_init event doesn’t fire where as page_load event fires each time the page loaded or reloaded. Page_load event occurs when all the objects become available for use. After page initialization and loading, system checks for change or action event fired at client side by any event of controls placed on the web page.

Now click here to create your first ASP.Net page

Spotlight.....

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , ,

Add comment


(Will show your Gravatar icon)  

  Country flag

[b][/b] - [i][/i] - [u][/u]- [quote][/quote]



Live preview

10/11/2008 3:33:19 AM




related videos.....
recent posts.....
top54u ezines.....