// Set parent window’s hidden field value from child window
window.opener.document.getElementById(Client ID of Hidden Field).value = Selected IDs;

// raise button click event of parent window
window.opener.document.getElementById(Client ID Of Button).click();

// Close the child window
close();

Fig – (1) Javascript on child window to raise button click event on parent window

I had written this script on child page. Tis will raise button click event and in post back I wrote the logic of retrieving data from database for IDs set in hidden field and displayed them in grid.

Now the second way, call javascript function of parent window from child window.

<script language="Javascript" type="text/javascript">
    function CallAlert()
    {
        alert("This is parent window's alert function.");
    }
</script>

Fig – (2) Javascript on parent window.

<script language="Javascript" type="text/javascript">

    function SetParentWindowsHiddenFieldValue()
    {
        window.opener.document.getElementById("HiddenField1").value =
                            document.getElementById("TextBox1").value;
        return false;
    } 

    function CallParentWindowFunction()
    {
        window.opener.CallAlert();
        return false;
    }
</script>

Fig – (3) Javascript on child window

+ Recent posts