Maulik Soni

<ASP:MSLOG runat=”brain”>

  Home  |   Contact  |   Syndication    |   Login
  4 Posts | 13 Stories | 15 Comments | 3 Trackbacks

News

Article Categories

Archives

Post Categories

Book List

My Contribution

This post discuss about general ASP.NET 2.0 application and page framework.

Application Location Options- With ASP.NET 2.0 you have the options to create an application with followings:

  • File System – uses Visual Studio 2005 development server
  • Local IIS – uses IIS as web application server
  • FTP Site
  • Remote Site

Page Structure Options – ASP.NET 2.0 provides two paths fro structuring the code of your application.

  • Code Inline Model – All the code contained in a single aspx file
  • Code Behind Model – Code separation of the page's Business Logic from its presentation logic. Business logic is stored in .aspx.vb file whereas presentation logic stored in aspx file.

To code as InLine coding – while you create a new project don't check "put this code in separate file. Now in Visual Studio 2005 inline coding also supports intelli Sence.

New Code Behind model – select 'place code in separate file" checkbox.

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default"%>

The aspx page using the new ASP.NET 2.0 code behind model has some attributes in page directive different from those in ASP.NET 1.x.

CodeFile = Point to the code behind file which is used with this presentation page. In this case default.aspx.vb.

Inherits = this attribute was available in previous version of ASP.NET 1.x but very little used. The attribute specifies the name of the class that is bound to the page when the page is compiled.

The followings are the ASP.NET 2.0 page directives. ( for more info pl. loot at msdn)

  • @Page
  • @Master
  • @Control
  • @Import
  • @Implements
  • @Register
  • @Assembly
  • @PreviousPageType
  • @MasterType
  • @Output Cache
  • @Reference

 

 

ASP.NET 2.0 Page Events

Page Events – The followings are the new page events supported by ASP.NET 2.0

  • InitComplete - Indicates the initialization of the page is completed
  • LoadComplete – Indicates the page has been completely loaded into memory.
  • PreInit – Indicates the moment before a page has been loaded into memory.
  • PreRenderComplete – Indicates the moment directly before a page has been redirected in the browser.

The order of PAGE EVENTS

  1. PreInit
  2. Init
  3. InitComplete
  4. PreLoad
  5. Load
  6. LoadComplete
  7. PreRender
  8. PreRenderComplete
  9. Unload

Dealing with POSTBACK – in ASP.NET 1.x pages typically posted back to themselves in order to process events. For this reason you must differentiate between post for the first time a page is loaded by the end user and POSTBACK. Then you use either

If Page.IsPostBack=True then

'Do processing

End If

or

If Not IsPostBack then

'Do processing

End If

Cross Page Posting- In many cases developer wants that ability to post to another page and deal with the first page's control values on the page. This is now possible in ASP.NET 2.0 and it is quit simple propcess.

Example using Previouspage.FindControl method

  1. Create page1.aspx with textbox and 2 button control
  2. On 2nd button set text property = "post back to page2"
  3. Go to property window (F4) and locate PostBackURL propery of 2nd Button Control - and set it to"page2.aspx"
  4. Now create a Page2.aspx
  5. in page load event write followings:

dim pp_textbox1 as textbox

pp_textbox1=ctype(PreviousPage.FindControl("Textbox1"),textbox)

response.write(pp_textbox1.text)

Example using Public Property-

  1. in page 1 create public read only properties
  2. Public ReadOnly Property pp_TextBox1() as TextBox

    Get

    Return TextBox1

    End Get

    End Property

  3. Consuming the exposed properties from page1
  4. go to page2 SourceView
  5. Add followings
  6. <%@ PreviousPageType VirtualPath="page1.aspx"%>
  7. in page_load event write
  8. Response.write(PreviousPage.pp_TextBox1.text)

now, if the user directly request page2 – then previouspage will have null values. To prevent this error

use

ISCROSSPAGEPOSTBACK property.

Maulik Soni

posted on Saturday, February 25, 2006 2:35 PM

Feedback

# re: Application and Page Framework 3/27/2006 5:35 AM mp3 blog
nice to hear you again Ray.
keep a good work with your blog.

# re: Application and Page Framework 6/13/2007 10:02 AM Comfy - Educational toys
great post

# re: Application and Page Framework 6/17/2007 10:09 AM Hungary Real Estate
thank you man

# re: Application and Page Framework 6/17/2007 10:11 AM live expert advice
how did you found out about it?

# re: Application and Page Framework 8/26/2007 5:41 AM jew
great post! thank you!

# re: Application and Page Framework 8/27/2007 8:58 AM jew
thank you, this is a great post

# re: Application and Page Framework 8/29/2007 5:49 AM jews
some useful stuff. 10x!

# re: Application and Page Framework 8/29/2007 8:38 AM jew
excellent post, useful info

# re: Application and Page Framework 2/21/2008 6:33 PM reading tarot cards
excellent post, useful info

# re: Application and Page Framework 4/27/2008 3:37 AM nir
i agree

# re: Application and Page Framework 4/27/2008 3:37 AM dan
wonderful website

Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification: