Solved

Get the Returned value from a JavaScript showModalDialog then close the dialog.

Posted on 2009-04-09
5
794 Views
Last Modified: 2012-05-06
I am trying to return the showModalDialog's returnValue.  In the aspx page that I'm using for my dialog, I'm trying to set the window.returnValue then close the dialog.  When I run this I get an error stating that the property returnValue doesn't exist in the current object.  How on earth am I going to get the return value out of the dialog if the returnValue doesn't exist?  I am doing this in a .NET 1.1 web application.

All I want to do is call the dialog to confirm something with a "Yes" or "No" response then close the dialog and pass the value back to the calling page.

Please advise.
Here is the JavaScript to call the dialog:
var retVal = window.showModalDialog(dialogURL, args, options);									
if (retVal != null)
{
	if(retVal.split(',')[1] == true)
	{
		bolReturn = true;
	}
	else
	{
		bolReturn = false;
	}
}
 
Here is the script in the dialog page:
function Confirmation(choice)
{
	try
	{
		returnValue = choice;
	}
}

Open in new window

0
Comment
Question by:pldougless
  • 3
  • 2
5 Comments
 
LVL 3

Expert Comment

by:rbradberry
ID: 24110380
"returnVallue = choice;" should be "window.returnValue = choice;"

also, this is an IE only function, it will not work in FireFox
0
 

Author Comment

by:pldougless
ID: 24110414
Sorry, the code should have reflected window.returnValue.  I have tried "window.returnValue" and get the error when I do.  Also, when coding and using intellisense I don't see the returnValue member in the window object...it simply isn't there.
0
 
LVL 3

Expert Comment

by:rbradberry
ID: 24110519
are you calling that function from within the window?  window.returnValue is only available after the windows has closed.
0
 
LVL 3

Accepted Solution

by:
rbradberry earned 125 total points
ID: 24110536
basically you have to set the window.returnValue from within the window while it is open.  then you can only retrieve the value of after the window has closed.
0
 

Author Comment

by:pldougless
ID: 24110654
I am trying to set the window.returnValue in the dialog before it is closed...here is what I doing in the windows script:

Here is the script in the dialog page:
function Confirmation(choice)
{
      try
      {
            window.returnValue = choice;
            window.close();
      }
}

The error is encountered saying that the returnValue property doesn't exist.
0

Featured Post

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question