Page_Load

Discussion in 'ASP .Net' started by Tony Johansson, Jan 11, 2010.

  1. Hello!

    Page_Load event is called every time a page is loaded is the documentation
    saying.
    I just wonder what exactly does this mean ?

    If I have a request on a page and set a break point in this Page_Load it
    will stop there.

    //Tony
     
    Tony Johansson, Jan 11, 2010
    #1
    1. Advertisements

  2. "Tony Johansson" <> wrote in
    news:qGH2n.2$:

    > Page_Load event is called every time a page is loaded is the
    > documentation saying.
    > I just wonder what exactly does this mean ?


    It means it is called every time a page is loaded, which means every
    time there is a Request from a browser.

    Realistically, the pattern is:

    protected void Page_Load(object sender, EventArgs e)
    {
    if(!Page.IsPostBack)
    {
    //Stuff when the page is initially loaded (GET)
    }
    else
    {
    //Stuff that runs on 100% of Postbacks (POST)
    //Generally, you put code in event handlers
    //not here. If you find yourself coding here
    //you are probably using bad architecture.
    }
    }

    There are other events that run every time the page is requested. NOTE:
    Page_Load is for loading pages. It applies to all pages. If you have
    event handlers, put conditionals there.

    Peace and Grace,

    --
    Gregory A. Beamer (MVP)

    Twitter: @gbworld
    Blog: http://gregorybeamer.spaces.live.com

    *******************************************
    | Think outside the box! |
    *******************************************
     
    Gregory A. Beamer, Jan 11, 2010
    #2
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Patrick Kristiansen

    Page_Load or Page_Init

    Patrick Kristiansen, Mar 5, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    706
    Patrick Kristiansen
    Mar 5, 2004
  2. MeDhanush

    .ascx page_load event

    MeDhanush, Jun 24, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    3,749
  3. VB Programmer

    Tricky Question: Page_Load

    VB Programmer, Jun 30, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    452
    VB Programmer
    Jun 30, 2003
  4. Yan-Hong Huang[MSFT]
    Replies:
    6
    Views:
    857
    Yan-Hong Huang[MSFT]
    Jul 17, 2003
  5. Christian

    Page_Init() and Page_Load()

    Christian, Jul 16, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    910
    Cristian Suazo
    Jul 16, 2003
  6. bminder
    Replies:
    1
    Views:
    2,367
    nfedin
    Feb 23, 2004
  7. z. f.
    Replies:
    0
    Views:
    732
    z. f.
    Oct 19, 2004
  8. rockdale
    Replies:
    1
    Views:
    884
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    Nov 16, 2006
Loading...