S
Steve
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?
the calling class (windows form) from a dialog that was
shown modally using ShowDialog?
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?
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?
Scott Reynolds @eircom.net> said: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?
Steve said:Hans
that is interesting. When does the form get destroyed?
when 'Close' or 'Dispose' is called or-----Original Message-----
The Windows resources for the dialog get destroyed
freed automatically by garbage collectorwhen the dialog is closed.
The memory for the properties/internals of .Net object is
a 'Disposed/Destroyed' form. Though, it cannot be shownwhen it is not needed.
So, you can still read properties of
Exactly. Even More, you can forward properties of the dialog to properties of the controls andSteve. said:Hans,
So what you're saying is that if I show a dialog from a
function I have access to any variables contained in the
dialog until the function exits (presuming that all
references to the dialog where private within the function
and not public in the class). After the function exits the
references to the dialog are destroyed and the garbage
collector is free to destroy the dialog variables at any
time. Is this correct?