From the Modal Window use the return value ==== Look at msdn but this can be
any value or object such as an array of values. Don't set the document
opener to return the value such as opener.document.forms[0].value =
stringToReturn because then you tie yourself to using the popup form value.
function returnSoeIdValue(sSOEID){
returnValue = sSOEID;
window.close();
}
In the calling / opener page use code such as the following. I usually
passs the object which I want to set the value of into a function such as
the following. therefore I can use the modal page on more than one page on
my site. Don't forget to check the value before assigning it.
function retrieveSoeid(oObj){
sSOEID = window.showModalDialog("soeidSearch.asp",oObj.id,"dialogHeight:
400px; dialogWidth: 600px; center: Yes;help: No; resizable: No; status:
No;");
if(sSOEID){
oObj.value =sSOEID;
}else{
oObj.value ='';
}
}
and finally a little HTML code to start page: (you can use readonly so the
text can't be edited on the page.)
<input type=text id=theTextBox readonly onclick=retrieveSoeid(this)>
<input type=button value="Click me for a modal box"
onClick=retrieveSoeid(theTextBox) id=theButton>
I hope that amswers your question. Aim to reuse as much code as possible on
other pages. None of the modal stuff will work on any browser other than IE
5.5 and above. Netscape doesnot support the modal.
Steve said:
Can anyone recommend the best way to pass a string back to
the calling class (windows form) from a dialog that was
shown modally using ShowDialog?