Return values from modal form to main page

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
 
M

Mark Rae

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.
 
J

Jeffrey Palermo [MCP]

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
 
M

Mark Rae

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?
 
E

Eliyahu Goldin

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
 
M

Mark Rae

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.
 
J

Jeffrey Palermo [MCP]

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

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,681
Members
48,796
Latest member
Greg L.

Latest Threads

Top