473,385 Members | 1,958 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Close child window when parent closes in asp.net

Hi There,
I have a child window opened from aspx page using window.open. On the
child window, I have a button(New category) which opens a grandchild. I
also have a cancel button on the child window which when clicked should
close the child and the granchild windows. Can anybody suggest me how
this can be accomplished.

I am using image buttons to do this.
This is how I am implementing, but for some reason the 'win' is
undefined.

----in the aspx page
<script language="javascript">

var win
function openwin()
{
win =
window.open('NewCategory.aspx','NewCategory','widt h=320px,height=125px,left=250px,top=500px')
win.focus()
}
function closewin()
{
if (win && win.open)
win.close()
self.close()
}
</script>
---

---in the .cs
this.New_ImgBtn.Attributes["onclick"] = "openwin();";
this.Cancel_ImgBtn.Attributes["onclick"] = "closewin();";

I cannot call the closewin() in body as onunload = "closewin()" coz
this event fires as soon as the new window opens and closes it right
away...

Can somebody get back to me as soon as possible? Thanks a lot.

Nov 17 '05 #1
1 3393
Samy,

I'm doing this, and it works just fine. Are you declaring the script
block in the head of the HTML document, or in the HTML document itself? I
did it when it was in the head of the document, but it could be different if
you declared it in the middle of the actual HTML.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Samy" <sa************@gmail.com> wrote in message
news:11*********************@g14g2000cwa.googlegro ups.com...
Hi There,
I have a child window opened from aspx page using window.open. On the
child window, I have a button(New category) which opens a grandchild. I
also have a cancel button on the child window which when clicked should
close the child and the granchild windows. Can anybody suggest me how
this can be accomplished.

I am using image buttons to do this.
This is how I am implementing, but for some reason the 'win' is
undefined.

----in the aspx page
<script language="javascript">

var win
function openwin()
{
win =
window.open('NewCategory.aspx','NewCategory','widt h=320px,height=125px,left=250px,top=500px')
win.focus()
}
function closewin()
{
if (win && win.open)
win.close()
self.close()
}
</script>
---

---in the .cs
this.New_ImgBtn.Attributes["onclick"] = "openwin();";
this.Cancel_ImgBtn.Attributes["onclick"] = "closewin();";

I cannot call the closewin() in body as onunload = "closewin()" coz
this event fires as soon as the new window opens and closes it right
away...

Can somebody get back to me as soon as possible? Thanks a lot.

Nov 17 '05 #2

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

Similar topics

4
by: jrefactors | last post by:
>From the main page, there are lots of links to open new window. i.e. <a href="#" onClick="window.open('child1.html')">Open Child Window</a> If I close the main page, I want to close all child...
1
by: Joe D | last post by:
I think this is a simple question. But I am new to JS. Here is what I want to do: From a parent window, open a popup window (child) to get data from user, then user submit the request, close the...
2
by: Jacques Koorts | last post by:
Hi, I've managed to get the parent window close the child window (popup). I do this by the child calling the parent to close it. How can the child close itself without help from parent? So...
1
by: gopal srinivasan | last post by:
I need to know how to close a parent modal window when child modal window opens, also i need to know the syntax for writing document on the modal window on the fly, like what we do in case of...
2
by: John Dalberg | last post by:
I have a closed box system which opens an html page. The page closes by the system. I have access to the html page. I added code to open a child window from this page. However when the parent...
0
by: Samy | last post by:
Hi There, I have a child window opened from aspx page using window.open. On the child window, I have a button(New category) which opens a grandchild. I also have a cancel button on the child...
2
by: Paul | last post by:
Hi this is related to a previous post, hopefully just a bit clearer description o the problem. I have a parent form that opens a new form (child form) while still leaving the parent form open....
1
by: Bill Borg | last post by:
Hello all, Simple chat app, where the site owner has a master window with all requests for chat, status of each room, etc., and child windows for each separate chat in which the owner is...
4
by: bsm | last post by:
Hi, I have googled for my issue in this group. This question was asked many times and many solution was given. But I want clear cut solution for the issue. The issue is: I tried to capture...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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,...
0
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...

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.