How to make sure child window gets closed

S

SAL

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

Protected Sub lbEstValue_Click(ByVal sender As Object, ByVal e As
System.EventArgs)
Response.Write("<script>window.open('EstValueHelp.aspx','_help',
'width=400,height=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
 
S

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.EventArgs)
AddHelpScript()
End Sub

Protected Sub Page_LoadComplete(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.LoadComplete
Dim lb As LinkButton = gvAssets.HeaderRow.FindControl("lbEstValue")
If Not lb Is Nothing Then
lb.Attributes.Add("onClick", "doHelp()")
End If
End Sub

Protected Sub AddHelpScript()
Dim s As String
s = "<script> function doHelp(){window.open('EstValueHelp.aspx',
'_help', 'width=400, height=400');}</script>"
Page.ClientScript.RegisterStartupScript(Me.GetType(), "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
 
S

Steven Cheng

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:
(e-mail address removed).

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

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

--------------------
 
S

Steven Cheng

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:
(e-mail address removed).

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

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

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>Estimated 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
 
S

Steven Cheng

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.open" 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/Web_Languages/JavaScript/Q_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:
(e-mail address removed).

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

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

--------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top