Click here to Skip to main content
15,893,381 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

I have a Javascript that I called using the the
ScriptManager.RegisterClientScriptBlock
. The script will generate a Pop-up window where i can browse for the path of the file. When I click the OK button it will call a JS function:

C#
function SelectAndClose() {
            txtValue = document.getElementById('_browseTextBox');

            window.returnValue = txtValue.value;
            window.close();
            return false;
        }


I am quite confused on how I can pass the txtValue variable to the previous page and use the value to display in a textbox..any help is greatly appreciated.

Thanks!

Franco
Posted
Comments
ZurdoDev 24-Jul-12 16:12pm    
Can you be a little more specific. Your function is getting the value from _browseTextBox and passing it back to the caller. What part are you having trouble with?
Franco Cipriano 24-Jul-12 16:24pm    
I don't know how to get the return value from the function..I also tried to use Session in passing the value, but still it won't work.
jkirkerx 24-Jul-12 18:47pm    
Well you can't pass a value to the previous page, because it no longer exist.

If your refering to the current page being the previous page, and the popup setting a value in the current page that it's lies upon,

then just get the id of the textbox and set the value.
Franco Cipriano 25-Jul-12 8:33am    
Hi,

It will be used by other web pages, so there are other control IDs that will used the value returned by the function..

1 solution

Rewrite your function this way
JavaScript
function SelectAndClose() {
            txtValue = document.getElementById('_browseTextBox');
        if ((window.opener != null) && (window.opener && !window.opener.closed)) {
               window.opener.InvokeParent(txtValue.value);
        }
            window.close();
            return false;
        }

Now Write Following Function in script block of .aspx of Parent Page
XML
<script type="text/javascript">
    function InvokeParent(varValue){
      if(varValue != ""){
        // Write Required Statements to perform whatever operation
       }
    }
</script>
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900