Test your technical skills online, appear in Virtual Interview and be ready for job!
Twitter Twitter LinkedIn YouTube Google
Be Interview ready ! | Search
Make friends on DotNetFunda.com and expand your network!
Winners

Win Prizes

Announcements
Like us on Facebook
Sponsor
Top Blogs Author
Mon, 21-Apr-2014 Authors
All Time Authors
Samirbhogayta
9750
Satyapriyanayak
7575
Jvprabhusanthi
6150

Latest members | More ...


(Statistics delayed by 5 minutes)

Asp.Net content page/master page/web user control events life cycle in different scenario

Lokesh76
Posted by Lokesh76 under ASP.NET on 3/12/2011 2:18:29 AM | Points: 75 | Views : 23241 | Status : [Member]

This is my first blogs... so I'm quite confuse about how to describe what I want to explain here....ok let's start point to point


What I want to describe here is quite clear in title of this blog.. so we have different scenarios where I'm trying to explain page events life cycle.

Scenario 1: We have master page and content page then what should be the sequence of events in this scenario.
So I have master page "Site.Master" 


Now we have content page as 



when we run this program the output is 

Content Page PreInit Event
Master Page Init Event
Content Page Init Event
Content Page Load Event
Master Page Load Event

oh what happen with master page PreInit event... its not there ... Yes that's the catch ...that PreInit event fire in content pages only because this events introduce in Asp.Net 2.0. In Asp.Net 2.0 Microsoft introduce some new features like master page, Theme...etc so If we are using master page and want to changes theme or decide which master page need to be load at runtime then we need to use Content page PreInit event.

beside content page there is no significance of this events in master page, web user controls.
 
Scenario 2: In this case we have master page, content page and a web user control on master page only.
Now add a new web user control to project and put the code as below 





Ouput:

Content Page PreInit Event
Master:UserControl Init Event
Master Page Init Event
Content Page Init Event
Content Page Load Event
Master Page Load Event
Master:UserControl Load Event

Scenario 3: In this case we have master page, content page and a web user control on master page and content page on both

Now if we create new web user control and place this to content page then event cycle like ..



Content Page PreInit Event
Page:UserControl Init Event
Master:UserControl Init Event
Master Page Init Event
Content Page Init Event
Content Page Load Event
Master Page Load Event
Page:UserControl Load Event
Master:UserControl Load Event

Suggestion always welcome ... happy coding...


Thanks
Lokesh Kumar
Found interesting? Add this to:



Comments or Responses

Posted by: Poster on: 3/12/2011 | Level:Starter | Status: [Member] | Points: 15

Excellent debug of events Lokesh. Keep it up!


Posted by: Tripati_tutu on: 3/16/2011 | Level:Bronze | Status: [Member] | Points: 15

Nice one.

Posted by: Hariinakoti on: 5/16/2012 | Level:Starter | Status: [Member] | Points: 15

Excellent Lokesh

Posted by: Avi.Raj25 on: 1/3/2014 | Level:Starter | Status: [Member] | Points: 15

Great with very simple examples :)

Can be grasped easily!


Login to post response.

Comments / Responses
Select text & click toolbar to format. Formatting appears in viewmode only. HTML Tags are not allowed.
Bold Italic Underline Paragraph Title Code  Link 
 Wait ... Processing ..... please wait.