473,225 Members | 1,526 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,225 software developers and data experts.

Page_load event executing twice

hi all,

I have this .aspx page for which the Page_load event occurs twice. I found
out while debugging. After searching google, I tried checking with
Page.Ispostback method and also had "AutoEventWireUp" = false and also run
after removing this tag from page directive but still my page_load event
gets called twice.

I have 3 pages called Search.asp, Processing.aspx and ConfirmSearch.aspx.

Program flow is from Search.aspx --> Processing.aspx --> ConfirmSearch.aspx.

When user click on search button on Search.aspx page, pop up window
(processing.aspx) pops up saying search is in progress and in the
background, it loads confirmsearch.aspx page. When search is finished , pop
up window gets closed.

I have Search.aspx page where on button click I have this statement
string flag = "search";

Session.Add("flag",flag); // setting this flag so that I can check its
status in Processing Page.

Response.Write("<script type='text/javascript'
window.open('Processing.aspx?destPage=ConfirmSear ch.aspx','_blank','width=350,height=200');

</script>");

(this pop is shows that ur search request is being processed while in the
background it starts loading ConfirmSearch.aspx page )

on Page_load event of Processing.aspx, I have this code

protected void Page_Load(object sender, System.EventArgs e)
{ string flag = (string)Session["flag"];

if (flag == "search")

Label1.Text = "Search in progress";

if (flag == "clear")

Response.Write("<script>self.close();</script>");

}

Also I have this code as html part of Processing.aspx and I refresh this
page ever 3 sec to check if flag == clear, if so then close this pop up
window.

<head runat="server">

<META HTTP-EQUIV="REFRESH" CONTENT="3"> //refresh every 3 sec

<title>Please wait.....</title>

<script type="text/javascript">

function Begin()

{ window.opener.location.href = "<%= Request.QueryString["destPage"]%>"; }
//loads ConfirmSearch.aspx in back window

</script>
</HEAD>

<body onload="Begin()" >

Now in Page_load event of ConfirmSearch.aspx , I have this code ( i have
inserted thread.sleep() method instead of my search method)

protected void Page_Load(object sender, EventArgs e)

{

Thread.Sleep(20000); //waiting period

string flag = "clear"; //sets flag to "clear" & adds it to session
and this value gets checked in page Processing.aspx

Session.Add("flag", flag); // if flag == "clear" in
Processing.aspx, then that pop gets closed

}

Now my problem is even after pop up gets closed , Page_load event of
ConfirmSearch.aspx gets executed twice.

Could anyone please help me ?

thanks in advance
Jun 9 '06 #1
1 6876
Get rid of your Thread.Sleep and see what happen.

chanmm

"puja" <pu********@hotmail.com> wrote in message
news:Ou**************@TK2MSFTNGP03.phx.gbl...
hi all,

I have this .aspx page for which the Page_load event occurs twice. I found
out while debugging. After searching google, I tried checking with
Page.Ispostback method and also had "AutoEventWireUp" = false and also run
after removing this tag from page directive but still my page_load event
gets called twice.

I have 3 pages called Search.asp, Processing.aspx and ConfirmSearch.aspx.

Program flow is from Search.aspx --> Processing.aspx -->
ConfirmSearch.aspx.

When user click on search button on Search.aspx page, pop up window
(processing.aspx) pops up saying search is in progress and in the
background, it loads confirmsearch.aspx page. When search is finished ,
pop up window gets closed.

I have Search.aspx page where on button click I have this statement
string flag = "search";

Session.Add("flag",flag); // setting this flag so that I can check its
status in Processing Page.

Response.Write("<script type='text/javascript'
window.open('Processing.aspx?destPage=ConfirmSear ch.aspx','_blank','width=350,height=200');

</script>");

(this pop is shows that ur search request is being processed while in the
background it starts loading ConfirmSearch.aspx page )

on Page_load event of Processing.aspx, I have this code

protected void Page_Load(object sender, System.EventArgs e)
{ string flag = (string)Session["flag"];

if (flag == "search")

Label1.Text = "Search in progress";

if (flag == "clear")

Response.Write("<script>self.close();</script>");

}

Also I have this code as html part of Processing.aspx and I refresh this
page ever 3 sec to check if flag == clear, if so then close this pop up
window.

<head runat="server">

<META HTTP-EQUIV="REFRESH" CONTENT="3"> //refresh every 3 sec

<title>Please wait.....</title>

<script type="text/javascript">

function Begin()

{ window.opener.location.href = "<%=
equest.QueryString["destPage"]%>"; } //loads ConfirmSearch.aspx in back
window

</script>
</HEAD>

<body onload="Begin()" >

Now in Page_load event of ConfirmSearch.aspx , I have this code ( i have
inserted thread.sleep() method instead of my search method)

protected void Page_Load(object sender, EventArgs e)

{

Thread.Sleep(20000); //waiting period

string flag = "clear"; //sets flag to "clear" & adds it to
session and this value gets checked in page Processing.aspx

Session.Add("flag", flag); // if flag == "clear" in
Processing.aspx, then that pop gets closed

}

Now my problem is even after pop up gets closed , Page_load event of
ConfirmSearch.aspx gets executed twice.

Could anyone please help me ?

thanks in advance

Jun 9 '06 #2

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

Similar topics

7
by: Jay Douglas | last post by:
Hello all, I have a asp.net page that creates a pdf on the fly and sends the pdf down to the browser. When calling the page up in IE the Page_Load event is fried twice. This doesn't happen with...
0
by: RAJ | last post by:
This event appears to be invoked twice for absolutely no reason on only one of my ASP.Net web user controls. Although I've now overcome the problem by overriding the base classes OnLoad routine, I...
7
by: Jibey | last post by:
Hello: I'm facing a very strange problem. When I run my Web application in Visual Studio.NET the Page_Load event is not executing. Other events like a Button_Click are executing. It doesn't...
4
by: Julia | last post by:
Hi Everyone, I am using webbrowser control to post data to an aspx page. However, for some reason, the aspx page sometimes will execute page_load event twice, and sometimes execute it once. So I...
14
by: V. Jenks | last post by:
I'm a little rusty having not touched .NET for 6 months and I can't remember why Page_Load is happening twice in this code: private void Page_Load(object sender, System.EventArgs e) {...
4
by: Seraph | last post by:
Again, I'm rather new here, so if I fail to follow any etiquette, please forgive me and let me know what I've done wrong, but I think this might interest quite a few people. One of my colleaques...
6
by: Alex D. | last post by:
Is there any way that the Page_Load event is being executed more than one time without being explicitly called? ...I think is happening to me.. Thanks, Alex.
11
by: fiefie.niles | last post by:
I am using ASP.NET 2005 and I have a simple form. Page_Load calls a sub mySub that does not do anything (for testing purposes). But, Page_Load gets called twice. On every single ASPX page in my...
4
by: David C | last post by:
I spent the last four hours trying to figure out why Page_Load would execute twice. Even stranger was that everything within if (! IsPostBack){....} executed twice as well. There is no rhyme or...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...

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.