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. Advertising

  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. Advertising

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:
    583
    Patrick Kristiansen
    Mar 5, 2004
  2. MeDhanush

    .ascx page_load event

    MeDhanush, Jun 24, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    3,504
  3. bminder
    Replies:
    1
    Views:
    2,151
    nfedin
    Feb 23, 2004
  4. z. f.
    Replies:
    0
    Views:
    549
    z. f.
    Oct 19, 2004
  5. rockdale
    Replies:
    1
    Views:
    647
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    Nov 16, 2006
Loading...

Share This Page