473,382 Members | 1,404 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,382 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 6904
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.