简体   繁体   中英

Passing a variable from child page to parent page asp.net

I am trying to access the variables of child page in parent page without refreshing. I have tried the session but to read the session i have to click a button in parent page which I can't do. I have two pages parent.asp and child.asp , when I click a button on parent.asp second page child.asp is opened and the form is filled there I want to post these form values to parent page without refreshing the parent page and also without any other button click (worked on session but to read the session again I have to click the button which I don't want to do).

Please help me, thanks.

A solution could be using a basic encryption algorithm and just saving the variables in localstorage. That way the data would be protected from other websites the user visits but pages that you have given a key to could access the variables.

An example of this is below.

<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/aes.js"></script>
<script>
    var store = {
        put: function(id, variable, password){
            localStorage.setItem(
                id, 
                CryptoJS.AES.encrypt(variable, password)
            );
        },
        pull: function(id, password){
            return  CryptoJS.AES.decrypt(
                localStorage.getItem(id), 
                password
            );
        },
    };
 </script>

I get that by using

window.opener.document.getElementById('textbox1').value = document.getElementById('textboxchild').value

Thanks for your help and techhead55 good encryption method thanks for that one too.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM