how to communicate between 2 browser window?

F

Franck

Hello,
I try to communicate some data from a parent aspx page
to a child page
the only solution I have found was with

Response.Write("<body><script>window.showModalDialog(......)");

it works fine.

To transfert the data, I put those I need in Session variables and in
the page load after I close the modal windows I simply read them.

but the page opener in the background become blank when the child page
open....

this is a pb as no data can be viewed anymore...

Is there any workaround?


Thanks for any help?

Franck
 
B

Bruce Barker

you should open the dialog on the onopen event after the html has been
rendered.

<body onload=window.showModalDialog(......)">

a better approach would store the values in a hidden field, and have the
dialog page fetch the data from its parent windiw.

-- bruce (sqlwork.com)
 
J

jasonkester

It looks like you're opening this child window as soon as the page
loads. If so, wouldn't you have all the information you need to
populate the child at that time? Why not just pass the necessary
information on the querystring when you create the new window?

If you actually need to have the two windows communicate, you can do
this without a postback. The child will have a reference to its
parent, and you'll get a reference to your new window when you create
it. So in the child, you could say:

document.FormName.FieldName.value =
parent.document.ParentFormName.ParentFieldName.value;
// flip this around to push data back to the parent.

And in the parent, you can pull information back from the child just as
easilly:

var childWindow = ­window.showModalDialog(......);
document.FormName.FieldName.value = childWindow
..document.ChildFormName.ChildFieldName.value;


Jason Kester
Expat Software Consulting Services
http://www.expatsoftware.com/
 
S

sreejith.ram

I am not sure if I understood the problem correctly..

Response.Write("<script>window.showModalDialog('......aspx')</script>");
would cause any server side code after that statement to stop
processing until the modal dialog is closed. thats the default
behaviour of modal dialog..

instead try

Page.RegisterStartupScript("somename","<script>window.showModalDialog('urpopup.aspx')</script>");


To transfer data, you could use query parameters to pass values to
popup


window.showModalDialog('urpopup.aspx?param1=value2&param2=value2')


To receive value to the parent page , you will be able use the
returnValue property

more details here
http://msdn.microsoft.com/library/d...r/dhtml/reference/methods/showmodaldialog.asp
 

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

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top