Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > cause webpage one to reload when webpage two is closed.

Reply
Thread Tools

cause webpage one to reload when webpage two is closed.

 
 
Paul
Guest
Posts: n/a
 
      06-17-2008
Hi I tried a google search but could not find anything. I am trying to cause
one webpage to reload when a second web page is closed. The second webpage
loads data into a session variable and when closed I need to reload the first
page loading in the data from the session variable. Since I need to close
the sescond form just setting the post back url to the first page on the
close button from the second page is not quite what I am looking for.
--
Paul G
Software engineer.
 
Reply With Quote
 
 
 
 
Alexey Smirnov
Guest
Posts: n/a
 
      06-17-2008
On Jun 17, 9:19*pm, Paul <(E-Mail Removed)> wrote:
> Hi I tried a google search but could not find anything. *I am trying to cause
> one webpage to reload when a second web page is closed. *The second webpage
> loads data into a session variable and when closed I need to reload the first
> page loading in the data from the session variable. *Since I need to close
> the sescond form just setting the post back url to the first page on the
> close button from the second page is not quite what I am looking for.
> --
> Paul G
> Software engineer.


Hi Paul,

Try to add the following code to your second web page

<body onunload="opener.location.href=opener.location.hre f;">

You might be also interested to see the following thread
http://forums.asp.net/t/988319.aspx

Hope this helps
 
Reply With Quote
 
 
 
 
Paul
Guest
Posts: n/a
 
      06-17-2008
Hi, thanks for the response.
I tried adding
<body onunload="opener.location.href=opener.location.hre f;"></body>
to the source of the second page but get the error
element body can not be nested within element td. I placed the code as
follows in the second form aspx file.

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
Runat="Server">

<body onunload="opener.location.href=opener.location.hre f;"></body>


followed by several html tables.
Anyhow just wondering where to place the body tag?

Also the way the user gets to the second page from the first page is just a
hyperlink.
thanks.

--
Paul G
Software engineer.


"Alexey Smirnov" wrote:

> On Jun 17, 9:19 pm, Paul <(E-Mail Removed)> wrote:
> > Hi I tried a google search but could not find anything. I am trying to cause
> > one webpage to reload when a second web page is closed. The second webpage
> > loads data into a session variable and when closed I need to reload the first
> > page loading in the data from the session variable. Since I need to close
> > the sescond form just setting the post back url to the first page on the
> > close button from the second page is not quite what I am looking for.
> > --
> > Paul G
> > Software engineer.

>
> Hi Paul,
>
> Try to add the following code to your second web page
>
> <body onunload="opener.location.href=opener.location.hre f;">
>
> You might be also interested to see the following thread
> http://forums.asp.net/t/988319.aspx
>
> Hope this helps
>

 
Reply With Quote
 
Alexey Smirnov
Guest
Posts: n/a
 
      06-17-2008
On Jun 17, 10:28*pm, Paul <(E-Mail Removed)> wrote:
> Hi, thanks for the response.
> I tried adding
> <body onunload="opener.location.href=opener.location.hre f;"></body>
> to the source of the second page but get the error
> element body can not be nested within element td. *I placed the code as
> follows in the second form aspx file.
>
> <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
> Runat="Server">
>
> * <body onunload="opener.location.href=opener.location.hre f;"></body>
>
> followed by several html tables.
> Anyhow just wondering where to place the body tag?
>
> Also the way the user gets to the second page from the first page is just a
> hyperlink.
> thanks.
>
> --
> Paul G
> Software engineer.
>
>
>
> "Alexey Smirnov" wrote:
> > On Jun 17, 9:19 pm, Paul <(E-Mail Removed)> wrote:
> > > Hi I tried a google search but could not find anything. *I am trying to cause
> > > one webpage to reload when a second web page is closed. *The second webpage
> > > loads data into a session variable and when closed I need to reload the first
> > > page loading in the data from the session variable. *Since I need to close
> > > the sescond form just setting the post back url to the first page on the
> > > close button from the second page is not quite what I am looking for.
> > > --
> > > Paul G
> > > Software engineer.

>
> > Hi Paul,

>
> > Try to add the following code to your second web page

>
> > <body onunload="opener.location.href=opener.location.hre f;">

>
> > You might be also interested to see the following thread
> >http://forums.asp.net/t/988319.aspx

>
> > Hope this helps- Hide quoted text -

>
> - Show quoted text -


The BODY element contains all the content of a document, including TD
and TABLE. It can be nested within HTML element only. It seems that
you are using Master page and it means you should change a BODY
element of the Master page. If Master page is used for many Content
pages then you can either make a copy of it (to apply changes to the
BODY tag), or you can set your Master page body tag to:

<body id="mBody" runat="server">

Then add this on the page that has to be closed:

public void Page_Load(Object sender, EventArgs e)
{
HtmlGenericControl body =
(HtmlGenericControl)Master.FindControl("mBody");
body.Attributes.Add("onunload",
"opener.location.href=opener.location.href;");
}

I didn't test it, but I think it should work.
 
Reply With Quote
 
Paul
Guest
Posts: n/a
 
      06-17-2008
Hi, I was able to add the body tag, since I am using a master page I had to
create an id for the tag in the master page and set a public property, so
thinking I can now run a script possibly to reload the first window.
--
Paul G
Software engineer.


"Alexey Smirnov" wrote:

> On Jun 17, 9:19 pm, Paul <(E-Mail Removed)> wrote:
> > Hi I tried a google search but could not find anything. I am trying to cause
> > one webpage to reload when a second web page is closed. The second webpage
> > loads data into a session variable and when closed I need to reload the first
> > page loading in the data from the session variable. Since I need to close
> > the sescond form just setting the post back url to the first page on the
> > close button from the second page is not quite what I am looking for.
> > --
> > Paul G
> > Software engineer.

>
> Hi Paul,
>
> Try to add the following code to your second web page
>
> <body onunload="opener.location.href=opener.location.hre f;">
>
> You might be also interested to see the following thread
> http://forums.asp.net/t/988319.aspx
>
> Hope this helps
>

 
Reply With Quote
 
Paul
Guest
Posts: n/a
 
      06-17-2008
Hi, It works! I guess it must know what the parent window is to be able to
reload it.
Thanks!
--
Paul G
Software engineer.


"Alexey Smirnov" wrote:

> On Jun 17, 10:28 pm, Paul <(E-Mail Removed)> wrote:
> > Hi, thanks for the response.
> > I tried adding
> > <body onunload="opener.location.href=opener.location.hre f;"></body>
> > to the source of the second page but get the error
> > element body can not be nested within element td. I placed the code as
> > follows in the second form aspx file.
> >
> > <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
> > Runat="Server">
> >
> > <body onunload="opener.location.href=opener.location.hre f;"></body>
> >
> > followed by several html tables.
> > Anyhow just wondering where to place the body tag?
> >
> > Also the way the user gets to the second page from the first page is just a
> > hyperlink.
> > thanks.
> >
> > --
> > Paul G
> > Software engineer.
> >
> >
> >
> > "Alexey Smirnov" wrote:
> > > On Jun 17, 9:19 pm, Paul <(E-Mail Removed)> wrote:
> > > > Hi I tried a google search but could not find anything. I am trying to cause
> > > > one webpage to reload when a second web page is closed. The second webpage
> > > > loads data into a session variable and when closed I need to reload the first
> > > > page loading in the data from the session variable. Since I need to close
> > > > the sescond form just setting the post back url to the first page on the
> > > > close button from the second page is not quite what I am looking for.
> > > > --
> > > > Paul G
> > > > Software engineer.

> >
> > > Hi Paul,

> >
> > > Try to add the following code to your second web page

> >
> > > <body onunload="opener.location.href=opener.location.hre f;">

> >
> > > You might be also interested to see the following thread
> > >http://forums.asp.net/t/988319.aspx

> >
> > > Hope this helps- Hide quoted text -

> >
> > - Show quoted text -

>
> The BODY element contains all the content of a document, including TD
> and TABLE. It can be nested within HTML element only. It seems that
> you are using Master page and it means you should change a BODY
> element of the Master page. If Master page is used for many Content
> pages then you can either make a copy of it (to apply changes to the
> BODY tag), or you can set your Master page body tag to:
>
> <body id="mBody" runat="server">
>
> Then add this on the page that has to be closed:
>
> public void Page_Load(Object sender, EventArgs e)
> {
> HtmlGenericControl body =
> (HtmlGenericControl)Master.FindControl("mBody");
> body.Attributes.Add("onunload",
> "opener.location.href=opener.location.href;");
> }
>
> I didn't test it, but I think it should work.
>

 
Reply With Quote
 
Alexey Smirnov
Guest
Posts: n/a
 
      06-17-2008
On Jun 17, 11:25*pm, Paul <(E-Mail Removed)> wrote:
> Hi, It works! I guess it must know what the parent window is to be able to
> reload it.
> Thanks!
> --
> Paul G
> Software engineer.
>
>
>
> "Alexey Smirnov" wrote:
> > On Jun 17, 10:28 pm, Paul <(E-Mail Removed)> wrote:
> > > Hi, thanks for the response.
> > > I tried adding
> > > <body onunload="opener.location.href=opener.location.hre f;"></body>
> > > to the source of the second page but get the error
> > > element body can not be nested within element td. *I placed the code as
> > > follows in the second form aspx file.

>
> > > <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
> > > Runat="Server">

>
> > > * <body onunload="opener.location.href=opener.location.hre f;"></body>

>
> > > followed by several html tables.
> > > Anyhow just wondering where to place the body tag?

>
> > > Also the way the user gets to the second page from the first page is just a
> > > hyperlink.
> > > thanks.

>
> > > --
> > > Paul G
> > > Software engineer.

>
> > > "Alexey Smirnov" wrote:
> > > > On Jun 17, 9:19 pm, Paul <(E-Mail Removed)> wrote:
> > > > > Hi I tried a google search but could not find anything. *I am trying to cause
> > > > > one webpage to reload when a second web page is closed. *The second webpage
> > > > > loads data into a session variable and when closed I need to reload the first
> > > > > page loading in the data from the session variable. *Since I need to close
> > > > > the sescond form just setting the post back url to the first page on the
> > > > > close button from the second page is not quite what I am looking for.
> > > > > --
> > > > > Paul G
> > > > > Software engineer.

>
> > > > Hi Paul,

>
> > > > Try to add the following code to your second web page

>
> > > > <body onunload="opener.location.href=opener.location.hre f;">

>
> > > > You might be also interested to see the following thread
> > > >http://forums.asp.net/t/988319.aspx

>
> > > > Hope this helps- Hide quoted text -

>
> > > - Show quoted text -

>
> > The BODY element contains all the content of a document, including TD
> > and TABLE. It can be nested within HTML element only. It seems that
> > you are using Master page and it means you should change a BODY
> > element of the Master page. If Master page is used for many Content
> > pages then you can either make a copy of it (to apply changes to the
> > BODY tag), or you can set your Master page body tag to:

>
> > <body id="mBody" runat="server">

>
> > Then add this on the page that has to be closed:

>
> > public void Page_Load(Object sender, EventArgs e)
> > {
> > HtmlGenericControl body =
> > (HtmlGenericControl)Master.FindControl("mBody");
> > body.Attributes.Add("onunload",
> > "opener.location.href=opener.location.href;");
> > }

>
> > I didn't test it, but I think it should work.- Hide quoted text -

>
> - Show quoted text -


Great!
 
Reply With Quote
 
Paul
Guest
Posts: n/a
 
      06-17-2008
Hi just had one last question. Not sure if there is anything that can be
done about this but when webpage 2 reloads (I have some controls that
postback) It also causes webpage 1 to reload. Is there anyway to have page
one reload only when page two is closed? I guess the onunload event must
occure when page 2 postsback to the server? Thanks.
HtmlGenericControl body =

(HtmlGenericControl)Master.FindControl("MasterPage BodyTag");
body.Attributes.Add("onunload",
"opener.location.href=opener.location.href;");
--
Paul G
Software engineer.


"Alexey Smirnov" wrote:

> On Jun 17, 11:25 pm, Paul <(E-Mail Removed)> wrote:
> > Hi, It works! I guess it must know what the parent window is to be able to
> > reload it.
> > Thanks!
> > --
> > Paul G
> > Software engineer.
> >
> >
> >
> > "Alexey Smirnov" wrote:
> > > On Jun 17, 10:28 pm, Paul <(E-Mail Removed)> wrote:
> > > > Hi, thanks for the response.
> > > > I tried adding
> > > > <body onunload="opener.location.href=opener.location.hre f;"></body>
> > > > to the source of the second page but get the error
> > > > element body can not be nested within element td. I placed the code as
> > > > follows in the second form aspx file.

> >
> > > > <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
> > > > Runat="Server">

> >
> > > > <body onunload="opener.location.href=opener.location.hre f;"></body>

> >
> > > > followed by several html tables.
> > > > Anyhow just wondering where to place the body tag?

> >
> > > > Also the way the user gets to the second page from the first page is just a
> > > > hyperlink.
> > > > thanks.

> >
> > > > --
> > > > Paul G
> > > > Software engineer.

> >
> > > > "Alexey Smirnov" wrote:
> > > > > On Jun 17, 9:19 pm, Paul <(E-Mail Removed)> wrote:
> > > > > > Hi I tried a google search but could not find anything. I am trying to cause
> > > > > > one webpage to reload when a second web page is closed. The second webpage
> > > > > > loads data into a session variable and when closed I need to reload the first
> > > > > > page loading in the data from the session variable. Since I need to close
> > > > > > the sescond form just setting the post back url to the first page on the
> > > > > > close button from the second page is not quite what I am looking for.
> > > > > > --
> > > > > > Paul G
> > > > > > Software engineer.

> >
> > > > > Hi Paul,

> >
> > > > > Try to add the following code to your second web page

> >
> > > > > <body onunload="opener.location.href=opener.location.hre f;">

> >
> > > > > You might be also interested to see the following thread
> > > > >http://forums.asp.net/t/988319.aspx

> >
> > > > > Hope this helps- Hide quoted text -

> >
> > > > - Show quoted text -

> >
> > > The BODY element contains all the content of a document, including TD
> > > and TABLE. It can be nested within HTML element only. It seems that
> > > you are using Master page and it means you should change a BODY
> > > element of the Master page. If Master page is used for many Content
> > > pages then you can either make a copy of it (to apply changes to the
> > > BODY tag), or you can set your Master page body tag to:

> >
> > > <body id="mBody" runat="server">

> >
> > > Then add this on the page that has to be closed:

> >
> > > public void Page_Load(Object sender, EventArgs e)
> > > {
> > > HtmlGenericControl body =
> > > (HtmlGenericControl)Master.FindControl("mBody");
> > > body.Attributes.Add("onunload",
> > > "opener.location.href=opener.location.href;");
> > > }

> >
> > > I didn't test it, but I think it should work.- Hide quoted text -

> >
> > - Show quoted text -

>
> Great!
>

 
Reply With Quote
 
Alexey Smirnov
Guest
Posts: n/a
 
      06-18-2008
On Jun 18, 12:08*am, Paul <(E-Mail Removed)> wrote:
> Hi just had one last question. *Not sure if there is anything that can be
> done about this but when webpage 2 reloads (I have some controls that
> postback) It also causes webpage 1 to reload. *Is there anyway to have page
> one reload only when page two is closed? *I guess the onunload event must
> occure when page 2 postsback to the server? Thanks.
> HtmlGenericControl body =
>
> (HtmlGenericControl)Master.FindControl("MasterPage BodyTag");
> * * * * * * * * * *body.Attributes.Add("onunload",
> * * * * * * * * * "opener.location.href=opener.location.href;");
> --
> Paul G
> Software engineer.
>
>
>
> "Alexey Smirnov" wrote:
> > On Jun 17, 11:25 pm, Paul <(E-Mail Removed)> wrote:
> > > Hi, It works! I guess it must know what the parent window is to be able to
> > > reload it.
> > > Thanks!
> > > --
> > > Paul G
> > > Software engineer.

>
> > > "Alexey Smirnov" wrote:
> > > > On Jun 17, 10:28 pm, Paul <(E-Mail Removed)> wrote:
> > > > > Hi, thanks for the response.
> > > > > I tried adding
> > > > > <body onunload="opener.location.href=opener.location.hre f;"></body>
> > > > > to the source of the second page but get the error
> > > > > element body can not be nested within element td. *I placed the code as
> > > > > follows in the second form aspx file.

>
> > > > > <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
> > > > > Runat="Server">

>
> > > > > * <body onunload="opener.location.href=opener.location.hre f;"></body>

>
> > > > > followed by several html tables.
> > > > > Anyhow just wondering where to place the body tag?

>
> > > > > Also the way the user gets to the second page from the first page is just a
> > > > > hyperlink.
> > > > > thanks.

>
> > > > > --
> > > > > Paul G
> > > > > Software engineer.

>
> > > > > "Alexey Smirnov" wrote:
> > > > > > On Jun 17, 9:19 pm, Paul <(E-Mail Removed)> wrote:
> > > > > > > Hi I tried a google search but could not find anything. *I am trying to cause
> > > > > > > one webpage to reload when a second web page is closed. *The second webpage
> > > > > > > loads data into a session variable and when closed I need to reload the first
> > > > > > > page loading in the data from the session variable. *Since I need to close
> > > > > > > the sescond form just setting the post back url to the first page on the
> > > > > > > close button from the second page is not quite what I am looking for.
> > > > > > > --
> > > > > > > Paul G
> > > > > > > Software engineer.

>
> > > > > > Hi Paul,

>
> > > > > > Try to add the following code to your second web page

>
> > > > > > <body onunload="opener.location.href=opener.location.hre f;">

>
> > > > > > You might be also interested to see the following thread
> > > > > >http://forums.asp.net/t/988319.aspx

>
> > > > > > Hope this helps- Hide quoted text -

>
> > > > > - Show quoted text -

>
> > > > The BODY element contains all the content of a document, including TD
> > > > and TABLE. It can be nested within HTML element only. It seems that
> > > > you are using Master page and it means you should change a BODY
> > > > element of the Master page. If Master page is used for many Content
> > > > pages then you can either make a copy of it (to apply changes to the
> > > > BODY tag), or you can set your Master page body tag to:

>
> > > > <body id="mBody" runat="server">

>
> > > > Then add this on the page that has to be closed:

>
> > > > public void Page_Load(Object sender, EventArgs e)
> > > > {
> > > > HtmlGenericControl body =
> > > > (HtmlGenericControl)Master.FindControl("mBody");
> > > > body.Attributes.Add("onunload",
> > > > "opener.location.href=opener.location.href;");
> > > > }

>
> > > > I didn't test it, but I think it should work.- Hide quoted text -

>
> > > - Show quoted text -

>
> > Great! - Hide quoted text -

>
> - Show quoted text -


Hi Paul

The onUnload event is handled when you refresh the page as well.
So, to make your code triggered on close only you can try following:

1) add the following js-code to your Master page between <head> and </
head>

<script>
function doUnload()
{
if (window.event.clientX < 0 && window.event.clientY < 0)
{
opener.location.href=opener.location.href;
}
}
</script>

2) change code-behind, from

body.Attributes.Add("onunload",
"opener.location.href=opener.location.href;");

to

body.Attributes.Add("onunload", "doUnload();");

That should avoid the refresh of the parent window if child window has
been refreshed.
I hope it works

Cheers!

Alexey Smirnov [MVP]
 
Reply With Quote
 
Paul
Guest
Posts: n/a
 
      06-18-2008

Hi, thanks for the additional response. I tried the following but now it
appears that the first page is not reloading now but even when I close the
second page. To close the second page I am using an input button with the
following
<input id="btn_close" type="button" value="Close" onclick ="window.close()"
style="width: 100px" class="Button_sm" />.

Here is the code I added as specified, in the master page I added between
the head tags.
<script type="text/javascript">
function doUnload()
{
if (window.event.clientX < 0 && window.event.clientY < 0)
{
opener.location.href=opener.location.href;
}
}
</script>

In the code behind on the second webform (the one that when closed should
cause the first page to refresh)

HtmlGenericControl body =

(HtmlGenericControl)Master.FindControl("MasterPage BodyTag");
body.Attributes.Add("onunload", "doUnload();");
thanks.

--
Paul G
Software engineer.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
JavaScript refresh: <a href="#" onClick="window.location.reload( true );">Reload</a> Joshua Beall HTML 26 06-29-2007 06:31 PM
problem with reload(sys) (doing reload on the sys module) gen_tricomi Python 2 05-23-2006 10:03 AM
Is there an SNMP equivalent to "Reload in [x]" / "Reload cancel" commands? steve.chambers@gmail.com Cisco 5 05-20-2006 04:06 AM
will all these messages cause a problem . I am a new subscriber and my computer is downloading 100,000 messages. Will this cause any kind of a problem with my ability to store other items?? Camille White Camille White Computer Support 9 11-08-2004 01:13 AM
how to cause tomcat to automatically reload a changed javabean? Alex Hunsley Java 4 09-06-2004 01:30 PM



Advertisments