returning values from modal dialog boxes in asp.net

B

Brian Henry

If i have a window showing like this

<script>window.showModalDialog('../weblinks/default.aspx','','unadorned:yes'
);</script>

how can i get it to return a value to its calling page? I want to have a
list of values to click in the modal dialog box, and when they click on one
of the values it closes the window and returns the value to the calling
page. How would you do this in ASP.NET? thanks! (i need to use the value in
the asp.net page also once it's returned)
 
K

Kathy Burke

Easiest way would be to set a session variable, for example:

Session("pass_this") = lstSelect.SelectedItem.Text (or .Value if
your prefer)

Then refer to the session variable from any aspx page.

You could also pass it in a querystring or a form collection.

hth,

Kathy
 
J

Jose L Rodriguez

Brian,
on the modal page you can also add an onclick event to your ok and cancel
buttons. Then you can add some javascript like this

function doOK(myvariable) {
window.returnValue = myvariable;
window.close();
}
function doCancel() {
window.returnValue = "";
window.close();
}

then in the receiving page you set the window to a variable like this

var str =
window.showModalDialog('../weblinks/default.aspx','','unadorned:yes'

then test the str results

if (!str)
str = "";

if (str.length == 0)
{
return;
}
else
{
.....perform some actions
....force postback
}

HTH

Jose
 

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,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top