473,757 Members | 10,007 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Page Load event is called....

When I navigate to the next page using
Response.Rediec t("MyNextPage.a spx") current page Page_Load event is called.
What I may wrongly understood is that post back will happen whenever there
is any server side event happens, resulting in Page_load event. Page_Load is
also happening when I navigate to the next page. That means Page_load will
always happen when I navigate to the next page. Please correct me If I have
totally misunderstood this concepts.
Moore Smith

Nov 18 '05 #1
6 2956
On Tue, 6 Jul 2004 16:55:06 -0700, MooreSmnith <MS********@hot mail.com>
wrote:
When I navigate to the next page using
Response.Rediec t("MyNextPage.a spx") current page Page_Load event is
called.
What I may wrongly understood is that post back will happen whenever
there
is any server side event happens, resulting in Page_load event.
Page_Load is
also happening when I navigate to the next page. That means Page_load
will
always happen when I navigate to the next page. Please correct me If I
have
totally misunderstood this concepts.
Moore Smith



I think what you're saying is correct (I may not understand your
details). The Page_Load is called when the page is first loaded, or
posted back to, etc. Think of it as a Page object receives a request.
When a request comes in, it tries to find that page (via the URL) and
creates an instance of that Page class. This is because the web is
stateless, it has to recreate it each time (even tho .NET gives us a
little magic for keeping 'state' in other ways).

When you do a redirect, you are telling the browser in the current
response that the page it should load is somewhere else (a different URL);
the browser then makes a new (GET) request at this new URL, hence an
instance of your second page is created and loaded....

and the cycle goes on :)

--
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET
Nov 18 '05 #2
Every ASP.NET page is an instance of a class and therefore each page has its
own life cycle. Each page has a Page_Load event that is called as part of
the life cycle of every page, not just on post back. If you want certain
code to only run when a postback occurs you can test for it with
Page.IsPostBack .

Response.Redire ct results in a response being sent to the client,
instructing it (the client) to open a different page instead of the one
originally requested. Server.Transfer on the other hand occurs on the
server and skips the additional HTTP request but neither method will supress
the call to the Page_Load event handler on the next page.

"MooreSmnit h" <MS********@hot mail.com> wrote in message
news:eJ******** ******@TK2MSFTN GP12.phx.gbl...
When I navigate to the next page using
Response.Rediec t("MyNextPage.a spx") current page Page_Load event is called. What I may wrongly understood is that post back will happen whenever there
is any server side event happens, resulting in Page_load event. Page_Load is also happening when I navigate to the next page. That means Page_load will
always happen when I navigate to the next page. Please correct me If I have totally misunderstood this concepts.
Moore Smith


Nov 18 '05 #3
My question is when the response.Redire ct is executed, page_load event of
the page(Page 1) which has Response.Redire ct and the Redirected(Page 2) page
Page_load event is getting called. I am not understanding why the the
Page_Load event of Page 1 is called. Calling Page 2 Page_Load evevnt is
understandable.
Thanks for your answers and helping me to understand this flow.
Moore.
"EijiTek" <ei*****@comcas t.net> wrote in message
news:vq******** ************@co mcast.com...
Every ASP.NET page is an instance of a class and therefore each page has its own life cycle. Each page has a Page_Load event that is called as part of
the life cycle of every page, not just on post back. If you want certain
code to only run when a postback occurs you can test for it with
Page.IsPostBack .

Response.Redire ct results in a response being sent to the client,
instructing it (the client) to open a different page instead of the one
originally requested. Server.Transfer on the other hand occurs on the
server and skips the additional HTTP request but neither method will supress the call to the Page_Load event handler on the next page.

"MooreSmnit h" <MS********@hot mail.com> wrote in message
news:eJ******** ******@TK2MSFTN GP12.phx.gbl...
When I navigate to the next page using
Response.Rediec t("MyNextPage.a spx") current page Page_Load event is called.
What I may wrongly understood is that post back will happen whenever there is any server side event happens, resulting in Page_load event. Page_Load is
also happening when I navigate to the next page. That means Page_load

will always happen when I navigate to the next page. Please correct me If I

have
totally misunderstood this concepts.
Moore Smith



Nov 18 '05 #4
As I mentioned, each page has a life cycle therefore, requesting a page
starts the life cycle. In order to perform a redirect you have to be
executing code from the first page.

Where in Page1 are you making the call to Response.Redire ct()?
"MooreSmnit h" <MS********@hot mail.com> wrote in message
news:eh******** ******@TK2MSFTN GP11.phx.gbl...
My question is when the response.Redire ct is executed, page_load event of
the page(Page 1) which has Response.Redire ct and the Redirected(Page 2) page Page_load event is getting called. I am not understanding why the the
Page_Load event of Page 1 is called. Calling Page 2 Page_Load evevnt is
understandable.
Thanks for your answers and helping me to understand this flow.
Moore.
"EijiTek" <ei*****@comcas t.net> wrote in message
news:vq******** ************@co mcast.com...
Every ASP.NET page is an instance of a class and therefore each page has

its
own life cycle. Each page has a Page_Load event that is called as part of
the life cycle of every page, not just on post back. If you want certain code to only run when a postback occurs you can test for it with
Page.IsPostBack .

Response.Redire ct results in a response being sent to the client,
instructing it (the client) to open a different page instead of the one
originally requested. Server.Transfer on the other hand occurs on the
server and skips the additional HTTP request but neither method will

supress
the call to the Page_Load event handler on the next page.

"MooreSmnit h" <MS********@hot mail.com> wrote in message
news:eJ******** ******@TK2MSFTN GP12.phx.gbl...
When I navigate to the next page using
Response.Rediec t("MyNextPage.a spx") current page Page_Load event is

called.
What I may wrongly understood is that post back will happen whenever

there is any server side event happens, resulting in Page_load event. Page_Load
is
also happening when I navigate to the next page. That means Page_load

will always happen when I navigate to the next page. Please correct me If I

have
totally misunderstood this concepts.
Moore Smith




Nov 18 '05 #5
Yes,
I am making Response.Redire ct from page 1.
Thanks for your response. To conclude, to redirect to different page it has
to postback itself.
Moore
"EijiTek" <ei*****@comcas t.net> wrote in message
news:pM******** ************@co mcast.com...
As I mentioned, each page has a life cycle therefore, requesting a page
starts the life cycle. In order to perform a redirect you have to be
executing code from the first page.

Where in Page1 are you making the call to Response.Redire ct()?
"MooreSmnit h" <MS********@hot mail.com> wrote in message
news:eh******** ******@TK2MSFTN GP11.phx.gbl...
My question is when the response.Redire ct is executed, page_load event of
the page(Page 1) which has Response.Redire ct and the Redirected(Page 2) page
Page_load event is getting called. I am not understanding why the the
Page_Load event of Page 1 is called. Calling Page 2 Page_Load evevnt is
understandable.
Thanks for your answers and helping me to understand this flow.
Moore.
"EijiTek" <ei*****@comcas t.net> wrote in message
news:vq******** ************@co mcast.com...
Every ASP.NET page is an instance of a class and therefore each page has
its
own life cycle. Each page has a Page_Load event that is called as
part of the life cycle of every page, not just on post back. If you want certain code to only run when a postback occurs you can test for it with
Page.IsPostBack .

Response.Redire ct results in a response being sent to the client,
instructing it (the client) to open a different page instead of the

one originally requested. Server.Transfer on the other hand occurs on the
server and skips the additional HTTP request but neither method will

supress
the call to the Page_Load event handler on the next page.

"MooreSmnit h" <MS********@hot mail.com> wrote in message
news:eJ******** ******@TK2MSFTN GP12.phx.gbl...
> When I navigate to the next page using
> Response.Rediec t("MyNextPage.a spx") current page Page_Load event is
called.
> What I may wrongly understood is that post back will happen whenever

there
> is any server side event happens, resulting in Page_load event.

Page_Load
is
> also happening when I navigate to the next page. That means Page_load will
> always happen when I navigate to the next page. Please correct me If

I have
> totally misunderstood this concepts.
> Moore Smith
>
>
>
>
>



Nov 18 '05 #6
A redirect is not a postback nor does it require a postback to function. A
postback only occurs when you submit the webform such as with a button press
or other server side event triggered by a client side action. Within the
life cycle of a page certain events are called by the ASP.NET runtime such
as OnInit(), OnLoad(), and OnPreRender() regardless of whether a postback
has occured or not.

As I mentioned in my previous post, you can check Page.IsPostBack to
determine if a postback occured if you have code that you only want to run
when a postback occurs. Performing a postback is not necessary to call
Response.Redire ct or Server.Transfer though it it more common for the
redirection to occur after a postback.

Here's an example (not the greatest but it works) Say you have a production
system and you're replacing one page with another but you don't want to
update all of the links right now because there are too many to find them
all or multiple systems that you don't have control over reference the page.
You could add a call to Response.Redire ct() to perform the redirection to
the replacement page as soon as the page is requested or you could place a
note on the page telling people that the page has been replaced by another
page and you provide a Button (call it RedirectButton) control that, when
clicked, will call RedirectButton_ OnClick() which in turn calls
Response.Redire ct(). In either scenario, you'll be requesting Page1 which
will redirect to Page2 which means that a new instance of Page1 will be
created, the code for the page will execute, then when redirected, a new
instance of Page2 will be created and its code will be executed. One
mechanism requires a postback while the other doesn't. Whether the page
needs to perform a postback is determined by the needs of your application.

"MooreSmnit h" <MS********@hot mail.com> wrote in message
news:eE******** ******@TK2MSFTN GP12.phx.gbl...
Yes,
I am making Response.Redire ct from page 1.
Thanks for your response. To conclude, to redirect to different page it has to postback itself.
Moore
"EijiTek" <ei*****@comcas t.net> wrote in message
news:pM******** ************@co mcast.com...
As I mentioned, each page has a life cycle therefore, requesting a page
starts the life cycle. In order to perform a redirect you have to be
executing code from the first page.

Where in Page1 are you making the call to Response.Redire ct()?
"MooreSmnit h" <MS********@hot mail.com> wrote in message
news:eh******** ******@TK2MSFTN GP11.phx.gbl...
My question is when the response.Redire ct is executed, page_load event of the page(Page 1) which has Response.Redire ct and the Redirected(Page 2)
page
Page_load event is getting called. I am not understanding why the the
Page_Load event of Page 1 is called. Calling Page 2 Page_Load evevnt
is understandable.
Thanks for your answers and helping me to understand this flow.
Moore.
"EijiTek" <ei*****@comcas t.net> wrote in message
news:vq******** ************@co mcast.com...
> Every ASP.NET page is an instance of a class and therefore each page
has its
> own life cycle. Each page has a Page_Load event that is called as part
of
> the life cycle of every page, not just on post back. If you want

certain
> code to only run when a postback occurs you can test for it with
> Page.IsPostBack .
>
> Response.Redire ct results in a response being sent to the client,
> instructing it (the client) to open a different page instead of the

one > originally requested. Server.Transfer on the other hand occurs on the > server and skips the additional HTTP request but neither method will
supress
> the call to the Page_Load event handler on the next page.
>
> "MooreSmnit h" <MS********@hot mail.com> wrote in message
> news:eJ******** ******@TK2MSFTN GP12.phx.gbl...
> > When I navigate to the next page using
> > Response.Rediec t("MyNextPage.a spx") current page Page_Load event is > called.
> > What I may wrongly understood is that post back will happen whenever there
> > is any server side event happens, resulting in Page_load event.
Page_Load
> is
> > also happening when I navigate to the next page. That means Page_load will
> > always happen when I navigate to the next page. Please correct me
If I > have
> > totally misunderstood this concepts.
> > Moore Smith
> >
> >
> >
> >
> >
>
>



Nov 18 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
7677
by: laredotornado | last post by:
Hello, I am looking for a cross-browser way (Firefox 1+, IE 5.5+) to have my Javascript function execute from the BODY's "onload" method, but if there is already an onload method defined, I would like mine to run immediately after it. So in the code below, what JS would i need to add to my "myfile.inc" page so that I could guarantee this behavior? <!-- main page --> <html> <head> <script type="text/javascript">
2
6428
by: Colin Basterfield | last post by:
Hi, Hmmm, a strange one for me, but hopefully not for others... I have a base page which has virtual protected void PageLoadEvent(object sender, System.EventArgs e){} In the Page_Load method I call this
1
6958
by: WFB | last post by:
Hi, I have a base class from which all of my pages derive (ABCBasePage). For example, ABCCustomerSelect Inherits ABCPasePage. I would now like to have ABCPocketSelect which should inherit from ABCCustomerSelect. My problem is that when ABCPocketSelect is loaded the Page_Load event in ABCBasePage is called, followed by the load event for ABCCustomerSelect - and I would like to skip the ABCCustomerSelect load event.. My basic code is...
2
5005
by: Sam | last post by:
I have a custom control (MyTextBox - taken from Microsoft website) that implements the IPostBackDataHandler interface. It is added to the controls collection of a placeholder control during the Page Load of a main ASPX page. Now if we debug the MyTextBox, we find the order of events like so (during a Posback, of course): OnInit -> OnLoad -> LoadPostData. My question is why does the LoadPostData occur *after* the OnLoad instead of...
3
1625
by: markeboy | last post by:
I am wanting to control when a page is loaded using a separate class to manage when and how it should be loade My current implementation needs to set a property of the page programatically (through a defined interface on the page) I can create an instance of the code behind class (and interface) that the page inherits and implements, however, I have no way of then calling it to load Of course, this was quite possible in VB6, by...
2
3628
by: John Lau | last post by:
Hi, Is there documentation that talks about the page lifecycle, the lifecycle of controls on the page, and the rendering of inline code, in a single document? Thanks, John
2
1382
by: Joey Lee | last post by:
Hi, Is there any situation where the PageLoad event is not called when a postback is made from and event? Strangely, I am facing a situation where DataGrid ItemCreated event is called first without going thru pageload when a postback is made? Any idea y this happen? Thank
8
3360
by: MaryA | last post by:
I have an aspx page that loads twice inspite of using the IsPostBack i removed all controls from the page and still the page_load event is called twice I appriciate any help coz i have lost several hours on this NB even i removed all events called on page load but still same problem Regards
3
21162
by: GauravGupta | last post by:
i want to know that is it posible to call button click event before page load event on post back.... please help me....
0
9489
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9298
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9906
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8737
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7286
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3829
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3399
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2698
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.