The web part lifecycle is described like this:

On Page Load

  1. Constructor
  2. OnInit
  3. OnLoad
  4. ConnectionConsumer method is called if web part is connectable
  5. CreateChildControls ...

On 1st Postback (PostBack click handler sets ViewState via public Property)

  1. Constructor
  2. OnInit
  3. CreateChildControls
  4. OnLoad
  5. PostBack click handling ...

On 2nd Postback (PostBack click handler sets ViewState via public Property)

  1. Constructor
  2. OnInit
  3. LoadViewState
  4. CreateChildControls
  5. OnLoad ...

As you can see the OnLoad and CreateChildControls change their order. This introduces some difficulties in my code as I need to gather various data which I used to do in the OnLoad element.

Is there any reason why the order is changed in the post back phase?

Edit
Report