469,934 Members | 2,589 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,934 developers. It's quick & easy.

WebApp Parent/Child windows

Hello All,
I'm working on a web app that will simulate a Windows app.

One of the items that I've trouble reproducing is the parent/child
interaction that might occur between a windo and popup custom dialog
box (example: right click an item and bring up a Config/Properties
dialog of the selected item).

In a Windows app, I can add a handler in the Parent to respond to the
"OK" event in the child window so that I can update the object's
poprties and reflect any changes on the parent Window.

In the web app, I haven't been able to figure out how to hook into the
PropertyPage's "OK" event from the parent window. It seems that once I
generate a "var propPage = window.open(..)" script, that the only link
between the two windows is the "window.opener" property or the
"propPage" variable. Even then, this is a javascript relationship, not
a .NET relationship.

Currently, to simulate the parent/child interaction, I currently do
this (more or less):
1.Pop up the config page (in a small window)
2. Get the user's selections
3. Store the user's selections in the Session
4. Refresh the parent
5. Parent loads, and scans the Session for the config info
6. Parent reflects any config changes on original form.
7. Parent clears the session variable that the child set.

Is there a better way to do this?

All ideas are welcome and appreciated.

-tomas
Nov 16 '05 #1
1 2061
Hi Tomas,
There are a lot of options. It sounds like what you want to do is
POST the settings dialog and then refresh the parent. If this is the
case, then open the dialog window, keeping the window handle in a var
(like I believe you already have). Then keep polling the the dialog
window to see if it has closed... When the dialog page has closed,
then post the original window back to .Net manually. The code I've
provided below is completely self-contained on the Parent window.
There are lots of other ways to do it, hope this helps you find your
final solution.
-Jerry

// CODE for IE and Mozilla
// Variable to hold settings dialog window handle
var subWin = "";
// will hold the timeout
var tmCheck = "";
// initialize type var
var myTypeS = typeof subWin;

// function to open dialog and prep
function ChangeSettings() {
// open the new win
subWin = window.open("mypage.html","settingsDlg","toolbar=n o,location=no,status=no")
;
// this is for Netscape
subWin.NSVar = 1;
//
window.onfocus = TimeRefreshThisWindow;
}

// function that sets timeout to check dialog
function TimeRefreshThisWindow() {
tmCheck = setTimeout("CheckDialog()",800);
}

// dummy function
function Nothing() {}

// function to check if dialog has closed
function CheckDialog() {
var myTypeS = typeof subWin.document;
// Has the dialog closed?
if ( ( navigator.userAgent.indexOf("IE") && myTypeS != "object" )
|| ( navigator.userAgent.indexOf("NS") && subWin.NSVar != 1 ) ) {
// bring the focus back to parent (me)
window.focus();
// refresh me (.Net must be expecting this pseudo postback,
handle it in your Page Load event or pass a control id to link it to
an event)
__doPostBack("<%=Me.ClientID%>:myControlId","") ;
// to avoid errors
window.onfocus = Nothing;
} else {
// the child still exists, make sure it has focus
subWin.focus();
}
}

// this function closes the dialog if the parent is closed
function CheckDlgOrphan() {
var myTypeS = typeof subWin.document;
if (myTypeS == "object") {
subWin.close();
}
}
// set onunload
onunload = CheckDlgOrphan;
Nov 16 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Paul | last post: by
3 posts views Thread by Maheshkumar.R | last post: by
1 post views Thread by Bill Borg | last post: by
3 posts views Thread by Eddie | last post: by
2 posts views Thread by epaetz | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.