ASP.NET,Javascript,Ajax: How to get a string from window.showModalDialog

Posted on 2009-12-22
Last Modified: 2012-05-08
Hi there,
I would like to know how I can get a string from a modal dialog and use it on the parent form using window.showModalDialog
Question by:karakav
    LVL 5

    Accepted Solution

    When you call showModalDialog you do this:
    var oReturnValue = showModalDialog(....);
    Within showModalDialog, assuming your textboxes have IDs of "txtForename" and "txtSurname":
    <body onbeforeunload="terminate();">
    function terminate()
      var o = new Object();
      o.forename = document.getElementById("txtForename").value;
      o.surname = document.getElementById("txtSurname").value;
      window.returnValue = o;

    LVL 2

    Expert Comment

    you can call the modal dialog page as
    var retVal = window.showModalDialog("ShowMailDetail.aspx

    and in the modal dialog before closing the window you have to set
    returnValue = "your return string should be specified here";
    LVL 14

    Expert Comment

    use window.returnValue in the document loaded in showModalDialog window. That can be accessed as a return value of the method call like below

    var returnData = window.showModalDialog("test.html");

    LVL 4

    Author Closing Comment


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
    Introduction HyperText Transfer Protocol ( or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
    The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
    The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

    779 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

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now