471,593 Members | 1,882 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,593 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 6650
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Jay Douglas | last post: by
reply views Thread by RAJ | last post: by
7 posts views Thread by Jibey | last post: by
14 posts views Thread by V. Jenks | last post: by
4 posts views Thread by Seraph | last post: by
6 posts views Thread by Alex D. | last post: by
11 posts views Thread by fiefie.niles | last post: by
4 posts views Thread by David C | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by Anwar ali | last post: by

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.