Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. page load precedence?

page load precedence?

Scheduled Pinned Locked Moved ASP.NET
helpquestion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    matsnas
    wrote on last edited by
    #1

    I have a LoginControl.ascx control and a ListItems.aspx page. Thay are placed in a MasterPage.master. I want the login control to be able to handle manual login as well automatic login from reading a cookie. Depening on the login result the list will display different set's of items. My problem is that when starting the ListItems.aspx the order of page load is: 1. ListItems_PageLoad (displaying a list of item based on NOT logged in state) 2. Master_PageLoad 3. LoginControl_PageLoad (automatically logging in the user) This means that the list is displayed on the NOT logged in state and I have to refresh the page to get the correct list. If I click logout in the logincontrol the list is rendered in the same way: 1. ListItems_PageLoad (displaying a list of item based on LOGGED IN state) 2. Master_PageLoad 3. LoginControl_PageLoad (logout the user) How should I go about programming to get the result I want? 1. ListItems_PageLoad (Initalize the login procedure) 2. Master_PageLoad 3. LoginControl_PageLoad (loggin out the user) 4. ListItems_PageLoad (complete the load, displaying a list of item based on LOGGED IN state) What am I missing?

    C 1 Reply Last reply
    0
    • M matsnas

      I have a LoginControl.ascx control and a ListItems.aspx page. Thay are placed in a MasterPage.master. I want the login control to be able to handle manual login as well automatic login from reading a cookie. Depening on the login result the list will display different set's of items. My problem is that when starting the ListItems.aspx the order of page load is: 1. ListItems_PageLoad (displaying a list of item based on NOT logged in state) 2. Master_PageLoad 3. LoginControl_PageLoad (automatically logging in the user) This means that the list is displayed on the NOT logged in state and I have to refresh the page to get the correct list. If I click logout in the logincontrol the list is rendered in the same way: 1. ListItems_PageLoad (displaying a list of item based on LOGGED IN state) 2. Master_PageLoad 3. LoginControl_PageLoad (logout the user) How should I go about programming to get the result I want? 1. ListItems_PageLoad (Initalize the login procedure) 2. Master_PageLoad 3. LoginControl_PageLoad (loggin out the user) 4. ListItems_PageLoad (complete the load, displaying a list of item based on LOGGED IN state) What am I missing?

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Use the Prerender event for some of this ( and if you're in .NET 2.0, there are even more events to choose from ), which will allow you to control the order. That is, the Page_load happens before the prerender, so putting something in the prerender, will force it to run later.

      Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

      M 1 Reply Last reply
      0
      • C Christian Graus

        Use the Prerender event for some of this ( and if you're in .NET 2.0, there are even more events to choose from ), which will allow you to control the order. That is, the Page_load happens before the prerender, so putting something in the prerender, will force it to run later.

        Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

        M Offline
        M Offline
        matsnas
        wrote on last edited by
        #3

        Thanx for the reply, I think you pointed me in the right direction. I found this article from Vivek Thakur. http://www.codeproject.com/useritems/lifecycle.asp[^] From where the page life-cycle-summary is: 1. OnPreInit 2. OnInit 3. (LoadViewState) ONLY ON POSTBACK 4. (LoadPostBackData) ONLY ON POSTBACK 5. Page_Load 6. (recusive Page_Load's for masterpages, other pages, controls) 7. Control Event Handlers (like Button1_Click()) 8. PreRender 9. (recusive PreRender's for mas...) 10. SaveViewState 11. Render 12. (recusive Render's for mas...) 13. Unload ...and from what I can gather, if dependent of the state of user controls placed in a masterpage, I should put the code in prerender as you said. How come all beginner tutorials are so focused on Page_Load then?

        C 1 Reply Last reply
        0
        • M matsnas

          Thanx for the reply, I think you pointed me in the right direction. I found this article from Vivek Thakur. http://www.codeproject.com/useritems/lifecycle.asp[^] From where the page life-cycle-summary is: 1. OnPreInit 2. OnInit 3. (LoadViewState) ONLY ON POSTBACK 4. (LoadPostBackData) ONLY ON POSTBACK 5. Page_Load 6. (recusive Page_Load's for masterpages, other pages, controls) 7. Control Event Handlers (like Button1_Click()) 8. PreRender 9. (recusive PreRender's for mas...) 10. SaveViewState 11. Render 12. (recusive Render's for mas...) 13. Unload ...and from what I can gather, if dependent of the state of user controls placed in a masterpage, I should put the code in prerender as you said. How come all beginner tutorials are so focused on Page_Load then?

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          matsnas wrote:

          How come all beginner tutorials are so focused on Page_Load then?

          Because the stupid IDE generates page load and not page prerender methods. The most important thing to understand is that all events happen after load and before prerender, that's another reason that all rendering steps should take place in prerender, so they reflect the results of any events.

          Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups