returning values from modal dialog boxes in asp.net

  • Thread starter Thread starter Brian Henry
  • Start date Start date
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)
 
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
 
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
 
Back
Top