Click to See Complete Forum and Search --> : Showmodaldialog problem


VChellam1972
August 18th, 2004, 11:46 PM
HI all,

I am finding a very peculiar problem. I have two pages. From the first
page on button click i have javascript function which it turn opens
modal dialog box with second page as a parameter to it. From the
second page, when i click ok, i set some return value to the window
and then want to retieve the return value from the fist page where
showmodaldialog was called. but the return value always shows
undefined? does anyone came across this problem or have any other
solution to work on this?

riteshtandon
August 19th, 2004, 12:32 AM
what it seems to me in the first instance is a problem of cyclic associations. It would be much better if u can explain it more clearly and in detail.

VChellam1972
August 19th, 2004, 09:44 AM
First page main.aspx.

I Have a update button. Onclick of ok button is mapped to javascript functon like this


function onupdate()
{

var res = window.showmodaldialog("child.aspx");
alert(res) /// this part is coming undefined

}


second page - child.aspx


i have a ok button wich is mapped to javascript function like this

functon onOk()
{
window.returnvalue = 1;
window.close();

}

so i set the return value and then call window.close which in turn should be returned in the first page java script function. The var res is always coming undefined as i am expecting 1 there

wey97
August 19th, 2004, 11:46 AM
See if my tutorial from my signature helps. If not I can try to post some code.

VChellam1972
August 19th, 2004, 01:32 PM
Hi

if compile and run ur project it works fine. IN my child window if i use asp buttons and when i click and put the same code for Set data , it doesn't close the window even though there is window.close


if you can give me ur email, i can send u my aspx files and java script code.
This is very urgent, please helpe me

venkat

wey97
August 19th, 2004, 01:46 PM
In your popup page, you have to add

<base target="_self"> inside the <head></head> html code.

VChellam1972
August 19th, 2004, 02:08 PM
I am not returning array of values.

On my ok button, of child page i have this java script


void SetData(){

var str1=1;
var winArgs = new Array(str1);
// pass the values back as arguments
window.returnValue = str1;
window.close();


}


On the main page i have these

void OnConfirm()
{

var str = window.ShowModalDialog("child1.aspx");
if(st1 == 1) i get undefined value here.
// do somethings
}

VChellam1972
August 19th, 2004, 02:12 PM
if i want to put the return value in alert what do i do? Now i think i am pretty close, just want to know how to check the return value against some interger value or string value or how should i set it if i am not reading it from any text box

wey97
August 19th, 2004, 02:24 PM
The reason you get undefined is you are checking 'st1' which is never defined.

You have:
var str = window.ShowModalDialog("child1.aspx");

so you should check to see if(str == 1)

alert(str);

VChellam1972
August 19th, 2004, 03:33 PM
thank you it works. Thansk for your help