Return values from modal form to main page

  • Thread starter Thread starter Mark Goldin
  • Start date Start date
M

Mark Goldin

I have main aspx page with a button that will show a modal
dialog in the Browser when a user clicks on the button.
On the modal form the user will do some selections.
The he will submit his selections to the server via a postback.
How can I take these selections to the main page?

Thanks
 
Mark Goldin said:
I have main aspx page with a button that will show a modal
dialog in the Browser when a user clicks on the button.
On the modal form the user will do some selections.
The he will submit his selections to the server via a postback.
How can I take these selections to the main page?

I have been struggling with the same problem recently and have come to the
conclusion that I need to rethink the whole architecture for the following
reaons:

1) AFAIK, window.showModalDialog(...) will only work for IE so, if you're
writing a public-facing site, you're going to run into severe cross-browser
issues.

2) It is possible to return only one value to the main form using the var
intReturnValue = window.showModalDialog(...) / window.returnValue
functionality so, if you need to return multiple values, pretty much your
only option is to use Session variables.

3) When you submit a modal dialog, it will launch a new browser instance
unless you enclose it in an iframe - again, this may not be supported in
certain browsers.
 
Mark,
I have overcome this by passing in "window" to the modal dialog. Then,
with this reference, client script can modify anything on the parent. If
you need pass information back to the parent, you could set some hidden form
fields on the parent through the window reference you have, and then post
the parent back to the server.

Best regards,
Jeffrey Palermo
 
I have overcome this by passing in "window" to the modal dialog. Then,
with this reference, client script can modify anything on the parent.

That's interesting - hadn't thought of that. Do you have a solution to the
submission problem too?
 
2) It is possible to return only one value to the main form using the var
intReturnValue = window.showModalDialog(...) / window.returnValue
functionality so, if you need to return multiple values, pretty much your
only option is to use Session variables.

returnValue is a variant. You can return an object with many fields. For
example, if you need to return value a=1, b=2 and c=3, you can make it in
the dialog window in the following way:

var outputObject=new Object();
outputObject.a=1;
outputObject.b=2;
outputObject.c=3;
window.returnValue=outputObject;

Eliyahu
 
returnValue is a variant. You can return an object with many fields. For
example, if you need to return value a=1, b=2 and c=3, you can make it in
the dialog window in the following way:

var outputObject=new Object();
outputObject.a=1;
outputObject.b=2;
outputObject.c=3;
window.returnValue=outputObject;

Excellent! Thanks very much.
 
Mark,
No, I haven't ever posted back a page from inside a dialog. I always
used javascript to place some values on my parent page (maybe in a hidden
form field), and then I close the dialog. If I have a onchange handler on
my hidden form field that changes, then I could tell the parent to post back
as soon as that value changes.

Best regards,
Jeffrey Palermo

Mark Rae said:
"Jeffrey Palermo [MCP]" <http://dotnetjunkies.com/weblog/jpalermo> wrote in
message
I have overcome this by passing in "window" to the modal dialog. Then,
with this reference, client script can modify anything on the parent.

That's interesting - hadn't thought of that. Do you have a solution to the
submission problem too?
 

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

Back
Top