Page_Load

T

Tony Johansson

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
 
G

Gregory A. Beamer

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! |
*******************************************
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,968
Messages
2,570,150
Members
46,697
Latest member
AugustNabo

Latest Threads

Top