Tutorial :Checking PostBack in .NET



Question:

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!


Solution:1

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.


Solution:2

Check out the ASP.NET Page Life Cycle


Solution:3

Also the following article article may be of some value.


Solution:4

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.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »