Connecting Tech Pros Worldwide Forums | Help | Site Map

Page_load event executing twice

puja
Guest
 
Posts: n/a
#1: Jun 9 '06
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'[color=blue]
>window.open('Processing.aspx?destPage=ConfirmSear ch.aspx','_blank','width=350,height=200');[/color]
</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



chanmm
Guest
 
Posts: n/a
#2: Jun 9 '06

re: Page_load event executing twice


Get rid of your Thread.Sleep and see what happen.

chanmm

"puja" <pujarpatel@hotmail.com> wrote in message
news:Ouv8sz4iGHA.4716@TK2MSFTNGP03.phx.gbl...[color=blue]
> 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'[color=green]
> >window.open('Processing.aspx?destPage=ConfirmSear ch.aspx','_blank','width=350,height=200');[/color]
> </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
>
>[/color]


Closed Thread