473,785 Members | 2,209 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to make sure child window gets closed

SAL
Hi,
VS2005 post
I'm opening a window using the following syntax:

Protected Sub lbEstValue_Clic k(ByVal sender As Object, ByVal e As
System.EventArg s)
Response.Write( "<script>window .open('EstValue Help.aspx','_he lp',
'width=400,heig ht=400');</script>")
End Sub

lbEstValue is a LinkButton

So, when the child window gets opened, if I don't close it and just click
back on the page that opened it, and then I close the parent page, the debug
environment doesn't stop debugging because there's still a window open. I'm
assuming this would lead to memory leaks on the server.
Is there a way I can make sure this child window gets closed?
There doesn't seem to be any page events that would be useful to me...

Any help would be much appreciate.

S
Sep 17 '08 #1
6 2072
"SAL" <SA*@nospam.nos pamwrote in message
news:O6******** ******@TK2MSFTN GP05.phx.gbl...
Any help would be much appreciate.
A couple of things:

1) Using Response.Write to write out JavaScript isn't recommended. Use this
instead:

ClientScript.Re gisterStartupSc ript(GetType(), "helpWindow ",
"window.open('E stValueHelp.asp x','_help', 'width=400,heig ht=400');", true);

or

ClientScript.Re gisterClientScr iptBlock(GetTyp e(), "helpWindow ",
"window.open('E stValueHelp.asp x','_help', 'width=400,heig ht=400');", true);

depending on when you want the script to run:
http://www.google.co.uk/search?sourc...entscriptblock
2) Debugging an ASP.NET app in Visual Studio is very different from running
an ASP.NET app in a production environment. When a browser window is open,
there is no permanent link back to the server. This is fundamental to the
disconnected architecture of browser-based applications. The browser sends a
request to the webserver, the webserver processes the request and sends back
a response to the browser - there is no permanent connection. After the
response has been sent, the server has no idea whether the browser window is
still open or not. So no memory leak.
3) As for making sure "child" windows get closed, there is really no
built-in mechanism for this. Have you considered moving to Visual Studio
2008? This would allow you to use the AJAX modal popup extender - then your
current problem would simply disappear. It would also make the modal popup
immune to popup blockers:
http://www.javascript-coder.com/wind...le-popup.phtml
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Sep 17 '08 #2
SAL
Mark,
thank you for your reply. I have added the following code to my page:

Page_Load(ByVal sender As Object, ByVal e As System.EventArg s)
AddHelpScript()
End Sub

Protected Sub Page_LoadComple te(ByVal sender As Object, ByVal e As
System.EventArg s) Handles Me.LoadComplete
Dim lb As LinkButton = gvAssets.Header Row.FindControl ("lbEstValue ")
If Not lb Is Nothing Then
lb.Attributes.A dd("onClick", "doHelp()")
End If
End Sub

Protected Sub AddHelpScript()
Dim s As String
s = "<scriptfunctio n doHelp(){window .open('EstValue Help.aspx',
'_help', 'width=400, height=400');}</script>"
Page.ClientScri pt.RegisterStar tupScript(Me.Ge tType(), "helpWindow ", s)
End Sub

Behavior is such:
The window opens the first time the linkbutton is click but not on
subsequent clicks. Also, it looks like the page is doing a postback when the
linkbutton is clicked. I have enableViewstate disabled.

I would like for the window to open up when ever the linkbutton is clicked.
The linkbutton is in the header of a gridview for a particular column. Also,
it would be nice if no postback occured.

Any other thoughts on this?

As to your #3 below, it would be really nice to go to vs2008, which I do
have installed on my machine, but, our company is stuck with IE6 for the
time being (there are apps in use that do not comply with IE7 and those are
not being migrated as of yet) and I have already played with popups in
VS2005 (AJAX) and the behavior is odd in IE6. Allen says this is a known
issue with IE6.

S

"Mark Rae [MVP]" <ma**@markNOSPA Mrae.netwrote in message
news:%2******** ********@TK2MSF TNGP06.phx.gbl. ..
"SAL" <SA*@nospam.nos pamwrote in message
news:O6******** ******@TK2MSFTN GP05.phx.gbl...
>Any help would be much appreciate.

A couple of things:

1) Using Response.Write to write out JavaScript isn't recommended. Use
this instead:

ClientScript.Re gisterStartupSc ript(GetType(), "helpWindow ",
"window.open('E stValueHelp.asp x','_help', 'width=400,heig ht=400');",
true);

or

ClientScript.Re gisterClientScr iptBlock(GetTyp e(), "helpWindow ",
"window.open('E stValueHelp.asp x','_help', 'width=400,heig ht=400');",
true);

depending on when you want the script to run:
http://www.google.co.uk/search?sourc...entscriptblock
2) Debugging an ASP.NET app in Visual Studio is very different from
running an ASP.NET app in a production environment. When a browser window
is open, there is no permanent link back to the server. This is
fundamental to the disconnected architecture of browser-based
applications. The browser sends a request to the webserver, the webserver
processes the request and sends back a response to the browser - there is
no permanent connection. After the response has been sent, the server has
no idea whether the browser window is still open or not. So no memory
leak.
3) As for making sure "child" windows get closed, there is really no
built-in mechanism for this. Have you considered moving to Visual Studio
2008? This would allow you to use the AJAX modal popup extender - then
your current problem would simply disappear. It would also make the modal
popup immune to popup blockers:
http://www.javascript-coder.com/wind...le-popup.phtml
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Sep 18 '08 #3
Hi SAL,

I think for normal browser window, it is really difficult to 100% ensure
parent or child window get closed since the other window may get closed by
user unexpectedly. for your scenario, is it possible that we make the new
window open as modal dialog? Thus, it will force the child windows to
finish before we continue operating on the main window. Otherwise, I still
think using ajax popup div should be the better approach.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsof t.com.

=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subs...#notifications.

=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
>From: "SAL" <SA*@nospam.nos pam>
References: <O6************ **@TK2MSFTNGP05 .phx.gbl>
<#5************ **@TK2MSFTNGP06 .phx.gbl>
>Subject: Re: How to make sure child window gets closed
Date: Thu, 18 Sep 2008 10:52:05 -0700
>
Mark,
thank you for your reply. I have added the following code to my page:

Page_Load(ByVa l sender As Object, ByVal e As System.EventArg s)
AddHelpScript()
End Sub

Protected Sub Page_LoadComple te(ByVal sender As Object, ByVal e As
System.EventAr gs) Handles Me.LoadComplete
Dim lb As LinkButton = gvAssets.Header Row.FindControl ("lbEstValue ")
If Not lb Is Nothing Then
lb.Attributes.A dd("onClick", "doHelp()")
End If
End Sub

Protected Sub AddHelpScript()
Dim s As String
s = "<scriptfunctio n doHelp(){window .open('EstValue Help.aspx',
'_help', 'width=400, height=400');}</script>"
Page.ClientScri pt.RegisterStar tupScript(Me.Ge tType(), "helpWindow ",
s)
>End Sub

Behavior is such:
The window opens the first time the linkbutton is click but not on
subsequent clicks. Also, it looks like the page is doing a postback when
the
>linkbutton is clicked. I have enableViewstate disabled.

I would like for the window to open up when ever the linkbutton is
clicked.
>The linkbutton is in the header of a gridview for a particular column.
Also,
>it would be nice if no postback occured.

Any other thoughts on this?

As to your #3 below, it would be really nice to go to vs2008, which I do
have installed on my machine, but, our company is stuck with IE6 for the
time being (there are apps in use that do not comply with IE7 and those
are
>not being migrated as of yet) and I have already played with popups in
VS2005 (AJAX) and the behavior is odd in IE6. Allen says this is a known
iss
Sep 23 '08 #4
Hi SAL,

Have you got any progress on this issue?

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsof t.com.

=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subs...#notifications.

=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>Content-Transfer-Encoding: 7bit
From: st*****@online. microsoft.com ("Steven Cheng")
Organization : Microsoft
Date: Tue, 23 Sep 2008 03:29:02 GMT
Subject: Re: How to make sure child window gets closed
>
Hi SAL,

I think for normal browser window, it is really difficult to 100% ensure
parent or child window get closed since the other window may get closed by
user unexpectedly. for your scenario, is it possible that we make the new
window open as modal dialog? Thus, it will force the child windows to
finish before we continue operating on the main window. Otherwise, I still
think using ajax popup div should be the better approach.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microso ft.com.

============== =============== =============== ======
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subs...#notifications.

============== =============== =============== ======
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
>>From: "SAL" <SA*@nospam.nos pam>
References: <O6************ **@TK2MSFTNGP05 .phx.gbl>
<#5*********** ***@TK2MSFTNGP0 6.phx.gbl>
>>Subject: Re: How to make sure child window gets closed
Date: Thu, 18 Sep 2008 10:52:05 -0700
>>
Mark,
thank you for your reply. I have added the following code to my page:

Page_Load(ByV al sender As Object, ByVal e As System.EventArg s)
AddHelpScript()
End Sub

Prot
Sep 25 '08 #5
SAL
Hi Steven.
Sorry for the slow response. No, I did not make any headway on this problem.
As I mentioned in my response to Mark, I can't really use AJAX because we
are stuck on IE6 for a while longer until some apps get upgraded. And, per
Allen, there are known redering issues with IE6 and AJAX popup panels...?

So, what I decided to do was just use a hyperlink server control that opens
up a new window by setting the target property on the hyperlink. In head tag
of the page I'm opening I used this javascript inline:

<head runat="server">
<script type="text/javascript">
window.resizeTo (600, 700);
</script>
<title>Estimate d Value Help Page</title>
</head>

It's not ideal I know but I couldn't get the other window to open up without
those ugly postbacks occuring and then the window not opening after the
first time.
I'd like to keep the menu and tools bars from showing up in this window
though. Is there an easy way to do that in that inline javascript above?

S
""Steven Cheng"" <st*****@online .microsoft.comw rote in message
news:u1******** ******@TK2MSFTN GHUB02.phx.gbl. ..
Hi SAL,

Have you got any progress on this issue?

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsof t.com.

=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subs...#notifications.

=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no
rights.
--------------------
>>Content-Transfer-Encoding: 7bit
From: st*****@online. microsoft.com ("Steven Cheng")
Organizatio n: Microsoft
Date: Tue, 23 Sep 2008 03:29:02 GMT
Subject: Re: How to make sure child window gets closed
>>
Hi SAL,

I think for normal browser window, it is really difficult to 100% ensure
parent or child window get closed since the other window may get closed by
user unexpectedly. for your scenario, is it possible that we make the new
window open as modal dialog? Thus, it will force the child windows to
finish before we continue operating on the main window. Otherwise, I still
think using ajax popup div should be the better approach.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@micros oft.com.

============= =============== =============== =======
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subs...#notifications.

============= =============== =============== =======
This posting is provided "AS IS" with no warranties, and confers no
rights.

--------------------
>>>From: "SAL" <SA*@nospam.nos pam>
References : <O6************ **@TK2MSFTNGP05 .phx.gbl>
<#5********** ****@TK2MSFTNGP 06.phx.gbl>
>>>Subject: Re: How to make sure child window gets closed
Date: Thu, 18 Sep 2008 10:52:05 -0700
>>>
Mark,
thank you for your reply. I have added the following code to my page:

Page_Load(By Val sender As Object, ByVal e As System.EventArg s)
AddHelpScript()
End Sub

Prot

Sep 26 '08 #6
Hi SAL,

As for controling the opened window(prevent it from show control or tool
bar), I'm afraid so far we can only do it at the opening stage. That means
when we use "window.ope n" javascript API to open the browser(by setting
some parameters). After the window has been opened, it's too late to
customize the windows style in its own document's javascript code.

BTW, have a look at this web thread:

http://www.experts-exchange.com/Web/..._20772577.html

some guys posted inline scripts suggestion which try opening a new browser
window(point to the same location as self window, then close the self
window). I don't think it's quite good idea, but worth a try in case you do
need to do it in the new window.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsof t.com.

=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subs...#notifications.

=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
>From: "SAL" <SA*@nospam.nos pam>
Subject: Re: How to make sure child window gets closed
Date: Fri, 26 Sep 2008 13:43:52 -0700
>
Hi Steven.
Sorry for the slow response. No, I did not make any headway on this
problem.
>As I mentioned in my response to Mark, I can't really use AJAX because we
are stuck on IE6 for a while longer until some apps get upgraded. And, per
Allen, there are known redering issues with IE6 and AJAX popup panels...?

So, what I decided to do was just use a hyperlink server control that
opens
>up a new window by setting the target property on the hyperlink. In head
tag
>of the page I'm opening I used this javascript inline:

<head runat="server">
<script type="text/javascript">
window.resizeTo (600, 700);
</script>
<title>Estimate d Value Help Page</title>
</head>

It's not ideal I know but I couldn't get the other window to open up
without
>those ugly postbacks occuring and then the window not opening after the
first time.
I'd like to keep the menu and tools bars from showing up in this window
though. Is there an easy way to do that in that inline javascript above?

S

Oct 1 '08 #7

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

Similar topics

2
18718
by: Irvin Amoraal | last post by:
Process: I have a form which uploads a file from client to server written in PHP. When the user presses the submit button, I use the "onSubmit" event to execute javascript to open a child window containing some text and an animated GIF. The javascript returns 'True' and the file is uploaded. All of that works great. Problem: Now I am trying to close the child window after the file has been uploaded. Below is the JavaScript I'm using:
3
2520
by: Kiki | last post by:
Hello, i wonder if anyone can help.. Is there a way of knowing from the parent window (var window;) that the child window (var newWindow) has been closed? i can't touch the child window's closed as this will be populated and managed by a client.. i need to know when this will be closed though to reload the parent window.. thanks
0
1358
by: Jon | last post by:
I am writing an MDI app that uses a document manager class to keep track of opened child windows. I want the user to be able to close a child window, but then re-open the window from the "Window" menu if they want. What happens to the child window after it is closed? Even though my document manager maintains the instance of the child and displays the name in the menu, when I try to use the show() method or the activate() method on a...
2
1633
by: Jon | last post by:
I am writing an MDI app that uses a document manager class to keep track of opened child windows. I want the user to be able to close a child window, but then re-open the window from the "Window" menu if they want. What happens to the child window after it is closed? Even though my document manager maintains the instance of the child and displays the name in the menu, when I try to use the show() method or the activate() method on a...
0
1721
by: Tom | last post by:
Let's say I have an MDI parent that has 5 open child windows in it. Now let's say that I have a function in the MDI parent that attempts to close all the child windows. It's starts running, closing the child windows; however, let's say that the second window it attempts to close has a Closing event and in that event (for whatever reason) the e.Cancel gets set to true (maybe the user is in the middle of something and doesn't want that window...
3
6329
by: Tom | last post by:
I am having a serious issue with my MDI child windows. This is with a large VB.NET application that I ported over to VS 2005 from VS 2003. The problem is that, if the child window is maximized and then closed, it produces the following error message: Cannot access a disposed object Object name:'icon' in source System.Drawing And then the whole system crashes. Again, this ONLY occurs if the MDI child window is maximized within the MDI...
71
10761
by: active | last post by:
In the main program I check to see if a certain form has been disposed. Does it make sense in that form's FormClosed event to do: Me.Dispose to make sure it is disposed the next time I check. Or is that automatic? Thanks
12
6237
by: Phil | last post by:
I can check for MdiChildren.Length=0, but which event handler should I put this in to detect when a child window is closed? TIA Phil.
0
9484
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10350
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10157
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8983
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7505
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5386
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5518
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3658
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2887
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.