views:

249

answers:

4

I come to you this time with a question to do with .NET. I was given the challenge of finding out the four steps involved with postback.

The exact challenge is:

"There are four methods executed each time there is a postback. Describe and identify each."

From what I can tell (this is a challenge for a .NET class), postback is what occurs when you submit a web form followed by the back button.

The only clues we are given are:

"First time a page is requested, is it a postback? No."

That's all I have. Anyone have any ideas or resources?

Thanks in advance!

+9  A: 

Check out the ASP.NET Page Life Cycle

Kevin Tighe
This was informative but not quite what I was looking for. Thank you for your time and help!
Enyalius
+2  A: 

Also the following article article may be of some value.

ojblass
An interesting link, but it didn't have what I needed and seemed to redirect me to a malware page...Thanks for trying.
Enyalius
Lol, I know that link from somewhere ;).
Wim Haanstra
A: 

You're wrong about the back button part - from Wikipedia:

A Postback is an action taken by an interactive webpage, when the entire page and its contents are sent to the server for processing some information and then, the server posts the same page back to the browser.

This is done to verify passwords for logging in, process an on-line order form, or other such tasks that a client computer cannot do on its own. This is not to be confused with refresh or back actions taken by the buttons on the browser.

I usually see this as links that say something like do_postback following by a string of (seemingly) random numbers.

Jared Harley
Thanks for pointing out my error. It got me a little bit closer to discovering the answer!
Enyalius
+4  A: 

These are my notes from Reflectoring the source at some point:

  1. LoadScrollPosition
  2. PerformPreInit
    • Fire PreInit Event
    • Initialize Themes
    • ApplyMasterPage
  3. InitRecursive
    • Recursively:
      • generate naming container ids for controls
      • set control.page property
      • init controls
    • set Page.Form property
    • Apply skin
    • Fire Init Event
  4. OnInitComplete
    • Fire InitComplete Event
  5. (if postback) LoadAllState
    • Load control state for registered controls
    • Load view state
  6. (if postback) ProcessPostData
    • Load PostData for controls implementing IPostBackDataHandler
  7. OnPreLoad
    • Fire PreLoad Event
  8. LoadRecursive
    • Fire Load Event
    • Recursively:
      • Load controls
  9. (if postback) ProcessPostData
    • Load leftover PostData for controls implementing IPostBackDataHandler
  10. (if postback) RaiseChangedEvents
    • Raise changed events for controls implementing IPostBackDataHandler
  11. (if postback) RaisePostBackEvent
    • Raise post back events for controls implementing IPostBackEventHandler
    • Validate
  12. OnLoadComplete
    • Fire LoadComplete Event
  13. PreRender
  14. SaveState
  15. Render

That makes LoadAllState, ProcessPostData, RaiseChangedEvents, and RaisePostBackEvent the ones that are only done on PostBack.

Mark Brackett
Doesn't the ProcessPostData occur during PostBack?
Enyalius
Yes - it's actually called twice. The 1st call (step 6) is (mainly) for markup controls to handle their POST data. After that, any dynamic controls re-added in Page_Load will get their POST data in the 2nd pass (step 9).
Mark Brackett
Ah, that was what was throwing me (wasn't reading close enough). Thank you so much for your help!
Enyalius