CodeVerge.Net Beta


   Explore    Item Entry    Members      Register  Login  
NEWSGROUP
.NET
Algorithms-Data Structures
Asp.Net
C Plus Plus
CSharp
Database
HTML
Javascript
Linq
Other
Regular Expressions
VB.Net
XML

Free Download:




Zone: > NEWSGROUP > Asp.Net Forum > windows_hosting.hosting_open_forum Tags:
Item Type: NewsGroup Date Entered: 6/11/2005 10:54:15 AM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 11 Views: 10 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
12 Items, 1 Pages 1 |< << Go >> >|
haidar_bilal
Asp.Net User
Page Life Cycle6/11/2005 10:54:15 AM

0/0

I guess this is the best place for my post, if not please my friends(moderators) move it.

I have a question about Page-Life Cycle in asp.net 2.0.
First of all:
1- PreInit() is called, where the personalization and themes data are initialized

2- Init() is called, in this stage, Each control on the page will initialize and configure its state.

--------------------------
TrackViewState() is called
--------------------------

3- Init() Complete, ensures that all page's controls have been initialized

4- Control State and View State: Control state first, where the state of the controls is being loaded, then View State is loaded. My question here is, I know that some controls might have specific properties that need to be loaded, and ViewState is usually for controls to load their state upon postback right? So, why do we need those two notions?

5- Load PostData: All controls that Implement IPostBackDataHandler, would load their values here. I wonder, in the previous point, we said controls load their state, what if those controls implements IPostBackDataHandler, this means that their state will be loaded in the previous method right? Then, my question would be, State doesn't include the data too? If yes, then  even if a control implements IPBDH, its postedback data won't be retrived here, since they were already retrieved before, when the control state was laoded right? If the state doesn't include loading data, then its fine.

6- PagePreLoad: Used only if you handle any event before pageLoading.

7- PageLoading method: It is fired for all child controls, up to the parent control. First of all, the page makes a second call to load postedback data right? Then, handles any callback event, then the control's events if fired, like textbox text changed.

8- PostBack events method: Events that have been defined by the user, for example, on click execute a certain method.

9- PageLoad event ends:

10: PreRender method: Ensures all controls have been created. Start rendering from the page control to the children control. Ensures that the personalization data, control and viewstate are saved.

11- Render method, where the markup is rendered of the page.

12- Page UnLoad.

I would like to know if this is the correct page-life cycle.
Differentiate between Control State loaded in the ControlState Loaded method and the LoadPostBack() method.

One thing also, usually when we say load post data, where would be saved, in viewstate?? It has always been a question for me. Smile [:)]

Now, I have a question about Cross-Page, can it be used for remote pages? I mean, can I post to a page that is not part of my web application? Or, it should be a local posted page?

Finally, I have a question about callback(). I guess after a call back there will be a page postback, but however, after pageload ends method, the RaiseCallBackEvent will get fired and no rendering, so callback() means only that no new rendering ? another postback, but the page's control won't be rendered again?


Regards
Bilal Hadiar, MCP, MCTS, MCPD, MCT
Microsoft MVP - Telerik MVP
wessamzeidan
Asp.Net User
Re: Page Life Cycle6/11/2005 12:06:50 PM

0/0

I can answer the question regarding the controlstate and viewstate. In ASP.NET 2.0, viewstate has been split into 2 parts, the normal viewstate that we already know from ASP.NET 1.x, and the new controlstate. Control state is basiclly viewstate that you can't disable, its used to save the state that the control cannot not function without. The ASP.NET guys invented it for performance reasons, usually when you want to minimize the size of the viewstate of a page, you disable the viewstate of some controls on the page, but by disabling the viewstate of a control, all the properties of that control loose its state between postbacks, and some of these properties are very critical for a control to function. So in ASP.NET 2.0, the state of these critical properties has been moved to controlstate, which cannot be disabled, but you can still disable the viewstate of the control.

Regarding the IPostBackDataHandler thing, controls that implement this interface load some properties from the data posted by the control. Lets take the textbox for example, lets say that you're requesting a page in which you change the value of the Text property of a text box in page load event, the value of this property will be saved in the viewstate. You change the value of the textbox in the browser and then do a postback. When page lifecycle reaches the loadviewstate stage, the Text property of the textbox gets loaded from the viewstate (which is the value that has been set in the page load event from the previous request). When the page life cycle reaches the load post data stage, the Text property gets loaded again, but this time with the data that you entered in the textbox in the browser. So the Text property gets loaded twice, once from the viewstate and once from the postback data.

Hope this explains some of your points.
Wessam Zeidan
WilcoB
Asp.Net User
Re: Page Life Cycle6/11/2005 12:26:20 PM

0/0


4- Control State and View State: Control state first, where the state of the controls is being loaded, then View State is loaded. My question here is, I know that some controls might have specific properties that need to be loaded, and ViewState is usually for controls to load their state upon postback right? So, why do we need those two notions?


Unlike viewstate, controlstate can not be disabled. Control state (generally/should) contain(s) state that a control relies on for it to work properly. For example, a datagrid in .NET 1.x which viewstate disabled doesn't properly page, etc. You were on your own when all you often wanted is disable all viewstate, except those few things that made the datagrid function properly (like paging). Control state solves this.


5- Load PostData: All controls that Implement IPostBackDataHandler, would load their values here. I wonder, in the previous point, we said controls load their state, what if those controls implements IPostBackDataHandler, this means that their state will be loaded in the previous method right? Then, my question would be, State doesn't include the data too? If yes, then  even if a control implements IPBDH, its postedback data won't be retrived here, since they were already retrieved before, when the control state was laoded right? If the state doesn't include loading data, then its fine.


The viewstate includes the previous data. The posted data is the current data (e.g. the new text in a textbox). It relies on the state data to be able to raise events like TextChanged.


7- PageLoading method: It is fired for all child controls, up to the parent control. First of all, the page makes a second call to load postedback data right? Then, handles any callback event, then the control's events if fired, like textbox text changed.


After the page was loaded, postback change events are raised, such as TextChanged.


10: PreRender method: Ensures all controls have been created. Start rendering from the page control to the children control. Ensures that the personalization data, control and viewstate are saved.


Add to that: register client script.


One thing also, usually when we say load post data, where would be saved, in viewstate?? It has always been a question for me.


It's not really saved - its usually posted by the user (e.g. from a textbox or some other kind of input field). Once its posted, it can be stored in the viewstate field (used by both control- and viewstate), so that after the next postback you still have this data. But in that case, its loaded in the control after the state is loaded, and not after postback data was loaded.


Now, I have a question about Cross-Page, can it be used for remote pages? I mean, can I post to a page that is not part of my web application? Or, it should be a local posted page?


Never tried it, but I'm sure that's not going to work. ASP.NET needs to be able to access the source files, and be able to do pretty much with it what it could do with any other (active) page. It needs to be able to build the control hierarchy, etc., so that you can use FindControl and stuff. Without the source, thats pretty much impossible.


Finally, I have a question about callback(). I guess after a call back there will be a page postback, but however, after pageload ends method, the RaiseCallBackEvent will get fired and no rendering, so callback() means only that no new rendering ? another postback, but the page's control won't be rendered again?


It's not really a postback. But stuff like viewstate is posted. During a callback, there's a slightly different and smaller life cycle. Nothing will be rendered for example. Instead, data is returned which will be available on the client (e.g. for "rendering" it there).

Your vision on the life cycle isn't 100% accurate (e.g. missing stuff like InitComplete, but overall I think you've got it pretty much at the right end.

- Wilco Bauwer / http://www.wilcob.com
haidar_bilal
Asp.Net User
Re: Page Life Cycle6/11/2005 2:43:48 PM

0/0

First of all, thank you Wessam and thank you WelcoB.

Regarding the page-life cycle, you mentioned WelcoB that I missed the InitComplete, well I knew about it in fact, but missed it in the post, you are right. Other than that, is there any thing still missing. To me, I beleive understanding the basic of how the request is going, better first than start with any new feature of the technology.

There is a conflict between what Wessam said and WelcoB.
Wessam said, the TextBox for example, will be loaded twice from the ViewState and the Postedback data, while WelcoB said that the ViewState will hold the previous data and the LoadPostData will have the current data, what do you think ?

I kind mixe between ViewState and LoadPostBackData, why do we have both? When we say the control state will load critical state of the control, will it load also the Data? I got to know what might be a good example of a critical state, from the example given by WelcoB, but why do we have those two seperate steps? ViewState and LoadPostBackData ? Does it mean we can now disable ViewState all the times? Since the controls will have their own ViewState? Do we need the ViewState for other needs than for controls? I don't think so, do you agree with me? do we still need ViewSate? Maybe ControlState loads only critical set right? So we still need the ViewState to load the other non-critical set, but here comes again, if the control's non-critical state is loaded by the ViewState, why do we still have LoadPostBackData?
Correct me if I am mistaken, LoadViewState will get back the control's state from the hidden fields right? then the LoadPostBackData will assign the data to controls from the ViewState? I am really kind of mixed here.

then, we have SaveViewState and SavePostBackData, the first will save the state in hidden fields, the second where will it save them?

Thanks  a lot.

WelcoB, it seems you are well knowledgable about ASP.NET 2.0, any good "special" resources you can point us to ?

Regards


Bilal Hadiar, MCP, MCTS, MCPD, MCT
Microsoft MVP - Telerik MVP
WilcoB
Asp.Net User
Re: Page Life Cycle6/11/2005 3:07:49 PM

0/0


I kind mixe between ViewState and LoadPostBackData, why do we have both?


Imagine the following. Someone enters some text in a textbox. After a postback is done, this text will be stored in the viewstate. If you would then postback again, the viewstate holds the data entered in the textbox. At that point, both LoadViewState and LoadPostBackData result in loading the same data twice, unless the textbox was made invisible, in which case only LoadViewState would load the text. The reason why the text is stored in viewstate is that it can both differentiate the previous text and the current text, and use that to determine whether TextChanged should be raised, and it can be used to 'remember' the entered text even when the textbox is made invisible after a postback.


I got to know what might be a good example of a critical state.


The current page in a datagrid.


do we still need ViewSate?


ViewState can still be used to decrease server load. For example, by enabling viewstate, you can prevent a query to be required on the server after a postback to bind a datagrid.


....and SavePostBackData...


SavePostBackData? There's no such thing. In case of a textbox, after the postback data was loaded, and a textbox knows that it should raise the TextChanged event, it can store the current value in the viewstate (and overwrite its previous value if applicable).


WelcoB, it seems you are well knowledgable about ASP.NET 2.0, any good "special" resources you can point us to ?


(It's Wilco ;)). Reflector is a great tool to understand what's going on under the hood. Nikhil Kothari's server controls & components is a great book. Those are the best 2 resources one needs, imo :). I've been developing production software since beta 1, which helped a lot to understand most of the things in ASP.NET 2.0.

- Wilco Bauwer / http://www.wilcob.com
haidar_bilal
Asp.Net User
Re: Page Life Cycle6/11/2005 3:23:39 PM

0/0

Hello, I didn't read your reply yet, but I got something while browsing through the reflector,
void IPostBackDataHandler.RaisePostDataChangedEvent()
{
this.OnTextChanged(EventArgs.Empty);
}

bool IPostBackDataHandler.LoadPostData(string postDataKey, NameValueCollection postCollection)
{
string text1 = this.Text;
string text2 = postCollection[postDataKey];
if (!text1.Equals(text2))
{
this.Text = text2;
return true;
}
return false;
}

What I conllcude is the following:
LoadPostData is only fired when the text inside the textbox is changed.
this means that the ViewState will always try to load data into the textbox, (old data)
Only, when text changes in the textbox, the LoadPostData will be fired,
Now this makes sense, and it seems that, both Wessam and Wiclo are correct why?
Its true what Wilco said, about "previous" and "current" data.
And Wessam said that the textbox will be loaded twice, well not sure I guess, ViewState will retain
the old value of the Textbox, only once inthe LoadViewState, and if nothing changed in the text,
then the TextBox will be previously loaded and no need to load it again, bt if text changed then
LoadPostData will fill the new data,

Is that right?

Regards



Bilal Hadiar, MCP, MCTS, MCPD, MCT
Microsoft MVP - Telerik MVP
WilcoB
Asp.Net User
Re: Page Life Cycle6/11/2005 3:36:24 PM

0/0

LoadPostData will be called for each control which posted data. In the case of the TextBox it will be loaded when text was entered in the textbox. Let me guide you through the LoadPostData implementation you pasted:

string text1 = this.Text; // The "previous" Text. The Text property gets the text from the viewstate.
string text2 = postCollection[postDataKey]; // The text in the textbox, e.g. the "current" posted text
if (!text1.Equals(text2)) // Check if the text is changed.
{
    this.Text = text2; // Update the current text (the Text property sets the text in the viewstate - so once SaveViewState is called, the current text will be stored in the viewstate)
    return true; // Data was changed, so return true so that the RaisePostDataChangedEvent method will be called.
}
return false; // No data was changed, so return false so that the RaisePostDataChangedEvent method will NOT be called.


- Wilco Bauwer / http://www.wilcob.com
wessamzeidan
Asp.Net User
Re: Page Life Cycle6/11/2005 3:53:22 PM

0/0

 haidar_bilal wrote:
And Wessam said that the textbox will be loaded twice, well not sure I guess, ViewState will retain
the old value of the Textbox, only once inthe LoadViewState, and if nothing changed in the text,
then the TextBox will be previously loaded and no need to load it again, bt if text changed then
LoadPostData will fill the new data


Well Bilal, when I said that value of the Text property will be loaded twice, I meant for the example I gave you. And as Wilco said, LoadPostData will be called any way for a textbox, the RaisePostDataChangedEvent method call depends on it.

Wessam Zeidan
haidar_bilal
Asp.Net User
Re: Page Life Cycle6/11/2005 4:10:23 PM

0/0

Ok, Ok, Ok
I got it now.
LoadPostData will always be called, it is used to track changes in the text of the TextBox, if textchanges, it will RaisePostBackEvent, else nothing will be called.
This explains to me why for example HyperLink doesn't implement IPostBackEventHandler, since no need to get anything from postback.
I kind of had problems all the time with ViewState and LoadPostData, I ued them for granted, but now I got the idea.

Thanks a lot Wessam and Wilco.

Regards


Bilal Hadiar, MCP, MCTS, MCPD, MCT
Microsoft MVP - Telerik MVP
clintonG
Asp.Net User
Re: Page Life Cycle9/9/2005 5:14:34 PM

0/0

I have unresolved issues in this same context that have brought development to a complete stand still. A LinkButton control within a Panel control will load a content page within a MasterPage when the LinkButton click event is raised but the LinkButton event does not PostBack and both the Panel and LinkButton disappear from the ViewState.

How can the content page even load without a PostBack? Why do the controls disappear from theViewState?

Please review this topic [1] and help me understand what can be done.

[1] http://forums.asp.net/1039817/ShowPost.aspx


<%= clintonG
Luis Abreu
Asp.Net User
Re: Page Life Cycle9/20/2005 9:28:01 PM

0/0

Hello.

regarding the cycle of the page, if i recall correctly, it'll try to load the data from the view state before preload and during the onload event. the 2nd load is a 2nd chance given to controls that were added dinamycally during the load event to populate their viewstate.

regarding the link problem, well i don't have the 2.0 version installed here, so i don't knwo what happens when you use the postbackutl property on a linkbutton (i'll check it out tomorrow).
--
Regards,
Luis Abreu
email: labreu_at_gmail.com
PT blog: http://weblogs.pontonetpt.com/luisabreu
EN blog:http://msmvps.com/blogs/luisabreu
http://www.pontonetpt.com
http://weblogs.pontonetpt.com/
clintonG
Asp.Net User
Re: Page Life Cycle9/21/2005 1:18:05 AM

0/0

I've resolved my issues.
The following page lifecycle resources may prove useful to others...


[1] http://msdn2.microsoft.com/en-us/library/ms178472
[2] http://robgarrett.com/Blogs/software/archive/2005/08/18/1524.aspx
<%= clintonG
12 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Pro ASP.NET 2.0 in VB 2005: From Professional to Expert Authors: Laurence Moroney, Matthew MacDonald, Pages: 1253, Published: 2006
Beginning ASP.NET 3.5 in VB 9.0: From Novice to Professional Authors: Matthew MacDonald, Pages: 1149, Published: 2007
Beginning ASP.NET 2.0 in C# 2005: From Novice to Professional Authors: Matthew MacDonald, Pages: 1148, Published: 2006
Programming ASP.NET: Building Web Applications and Services with ASP.NET 2.0 Authors: Jesse Liberty, Dan Hurwitz, Pages: 930, Published: 2006
ASP.NET 2.0 Web Parts in Action: Building Dynamic Web Portals Authors: Darren Neimke, Pages: 324, Published: 2007
Professional DotNetNuke 4: Open Source Web Application Framework for ASP.NET 2.0 Authors: Shaun Walker, Joe Brinkman, Bruce Hopkins, Scott McCulloch, Patrick J. Santry, Chris Paterra, Scott Willhite, Dan Caron, Pages: 517, Published: 2006
Oracle JDeveloper 10g for Forms & PL/SQL Developers: A Guide to Web Development with Oracle ADF Authors: Peter Koletzke, Duncan Mills, Pages: 562, Published: 2006
The Java EE 5 Tutorial: For Sun Java System Application Server Platform Edition 9 Authors: Eric Jendrock, Jennifer Ball, Debbie Carson, Ian Evans, Scott Fordin, Kim Haase, Pages: 1304, Published: 2006
Environmental Management in Practice: Managing the Ecosystem Authors: Bhaskar Nath, Pages: 297, Published: 1998
Breakthrough Thinking for Nonprofit Organizations: Creative Strategies for Extraordinary Results Authors: Bernard Ross, Clare Segal, Pages: 268, Published: 2002

Web:
ASP.NET Page Life Cycle Overview When an ASP.NET page runs, the page goes through a life cycle in which it performs a series of processing steps. These include initialization, instantiating ...
15 Seconds : The ASP.NET Page Life Cycle Solomon Shaffer explores the life cycle of an ASP.NET page from initialization to unloading. He also explains the various methods to override ASP.
CodeProject: ASP.NET Page Lifecycle. Free source code and ... Nov 4, 2006 ... This article discusses the important events in the ASP.NET page lifecycle alongwith the new compilation model in ASP.
ASP.NET Page Life Cycle In this article, we will see the stages of execution of the ASP.NET Page.
ASP.NET Page Life Cycle Explains life cycle of an ASP.NET page whether the page is requested for the first time or it is a postback.
ASP.NET Application Life Cycle Overview for IIS 5.0 and 6.0 NET page methods are automatically bound to events, such as the page's Page_Load event. For details, see ASP.NET Page Life Cycle Overview. ...
ASP.NET Page Life Cycle & Common Events The page request occurs before the page life cycle begins. When the page is requested by a ... Common Life-cycle Events. Page Event. Typical Use. PreInit ...
ASP.Net Page Life Cycle Nov 27, 2006 ... This article explains simple ASP.NET web page execution in depth.
ASP.NET 2.0 Page LifeCycle NET 2.0 Page LifeCycle to see what's new and different from ASP.NET 1.1. This chart was created by Leon Andrianarivony, and unfortunately the original URL ...
CodeProject: ASP.NET Page Life Cycle. Free source code and ... Apr 25, 2008 ... This article describes the life cycle of the page from the moment the URL is hit from the web browser till the HTML code is generated and ...

Videos:
"LIFE CYCLE" VIDEO (GG75 HOMEMADE) WWW.MYSPACE.COM/GG75 BUY MY DEBUT ALBUM AT THE ABOVE WEB PAGE. THANKS!! GG75 (: ----------------------------------------- MY 1ST-TIME H...
GG75 LIFECYCLE MUSIC VIDEO WWW.MYSPACE.COM/GG75 BUY MY DEBUT ALBUM AT THE ABOVE WEB PAGE. THANKS!! GG75 (:
ebaY Hacked! The Cover-Up Kicks into High Gear I am going to start focusing on how ebaY is covering up all the fraud, and asking whether laws are being broken. When people's accounts are compromi...
365 Days/365 Plays by Suzan-Lori Parks; Week 5 Atlanta: The Constant, or Action in Inaction WHAT IS 365 DAYS/365 PLAYS? On November 13, 2002 Suzan-Lori Parks got an idea to write a play a day for a year. She began that very day, finishing o...
Snakes Inside This clip is incorrectly titled "Schistosoma". We now suspect this worm is part of an insect life cycle that is the result of an insect depositing eg...
Does On Stage Marketing really give the support you need to SUCCEED?! Early-Stage Marketing for Start-Ups - ClickZ In fourth place, behind product development, recruiting and sales. Neil tells you how to spend wisely du...
Middle Class Lifeboat - Careers and Life Choices for Staying Peak Moment 127: Paul and Sarah Edwards are authors of a timely book "Middle-Class Lifeboat: Careers and Life Choices for Navigating a Changing Econo...
Satyam- Leadership Development Satyam's new leader development program takes a long-term investment approach rather than trying to churn out as many participants as possible. To t...
Red Salmon Never Get The Blues Live! at Calm Creek, Alaska Red Salmon Never Get The Blues Live! at Calm Creek, Alaska. If You Likee please rate comment and share with all your friends and fiends! click more s...
De Anza Cycle Park Hillclimb 1974 De Anza Cycle Park Hillclimb 1974 located in Riverside County Ca. Riders include; "Boo" (Dad), Uncle John, Uncle "Boogie", cousin "B" (RIP) and Myse...




Search This Site:










questions about subportals in dnn ( need some clarification before i can suggest a solution to my client )

what's up doc ?

setting the selectedvalue drop down list which is databound.

how to set portal to domain?

ttt authentication module troubles

datagrid and date

simple security question

quick skinning tip, ever needed a different skin color variation than was offered ?

how do i do this in c#?

looking for free or paid support with a out of the box working dnn 1.x to 2.0.4 upgrade that now has error “security exception”

asp image

response.flush causes page to loose theme ???

problem with rendering of tabstrip in updatepanel, which will be load on async postbak...

making new user for a website?

getting a webpart's id not to show up

ibs v dnn data access methods - please clarify

vs2008 download for msdn subscribers does not work

make asp:menu work on click

another www.love2trade.com code snippet (for db backup)

upgrading or not upgrading ?

add new item - web form - no master page option?

accessing the userid to view logged in user data with an sp

alternatives to pop-ups ???

access tablerow of current rendered cell

system.convert class

upload files in asp.net

any treeview client-side solutions for non-ie browsers? (netscape, mac ie, etc).

what treeview control is used for the msdn website?

using application id property or roles class to filter roles a user is able to assign

gotcommunitynet (general)

 
All Times Are GMT