SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict
    Join Date
    Feb 2002
    Location
    Atlanta, GA
    Posts
    342
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    OnPreRender - practical usage

    I've inherited an application and there's a lot of code which executes in the OnPreRender event on one of the pages. Essentially the code is setting / resetting the state of a number of items for use in On_Load.

    Here's my question: what are some practical uses for placing code in OnPreRender, aside from what I've noted above.

    Another question is, when OnPreRender completes, is it safe to say that any controls are ready for use in code from that point forward?

    Thanks!


  2. #2
    SitePoint Wizard silver trophy
    Join Date
    Sep 2002
    Location
    Cleveland, Ohio, USA
    Posts
    1,494
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PreRender is the last event to fire before, well, the rendering happens. It occurs after any postback handling as well, which makes it particularly ideal for data binding after you've done some kind of work.

    For example, the first time you visit a page, you bind some data to a grid. You do it PreRender. Now the user submits some new data, and the button click's event handler adds that data to the data store, and in PreRender, that new set of data is bound to the grid. I've seen a lot of people do this wrong, where they bind it twice, once in Load and then in the click handler.

    Load, as it turns out, is actually not a great place to do stuff, especially in control development.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •