PDA

View Full Version : How to close window with deep hierarchy


styleepop
Aug 13, 2007, 08:15 PM
Friends.. this is my first mesg to this group..
Thanks in advance..

When I click on CLOSE asp button.. it should do some saving process at server side and close that window and all its child windows if any.

How can I handle this situation.

I tried with window.close()
Its not working.

Actaully my page is inside an user control

The hirarchy is like the below..

1. Default.aspx(static)

Usercontrol(static)

Welcome.aspx page(static)

Usercontrol(static)

Welcomestep1.aspx(changes on button click)


Now I should close the enitire page from welcomestep1.aspx

jstrike
Aug 14, 2007, 10:48 AM
You can probably fake out a server call with some JavaScript.
(This is just off the top of my head, I'll let you try to implement it)


body onbeforeunload="saveInformation();"
.
.
.
script
function saveInformation() {
var srvrCall = new Image();
srvrCall.src = "http://url & parameters for your server side code";
}
/script


That's it in a nutshell. When you try to close the page the saveInformation function will get called. It will create an image object in JavaScript and set the source to whatever URL you want. The browser will naturally make a call out to that URL to try to retrieve the image. You can put your parameters on there and call your backend server code. Your code will get executed and the page will close.

I've done similar things before, using Java on the back end, with good results.

HTH.