Bharathi Dasan
Bharathi Dasan

Reputation: 59

How Can We Pass a Value From PopUpWindow to Aspx Page using JavaScript?

Im using the below function:

function GetRowValue(val) {
    window.opener.document.getElementById("UniqueKeyField").value = val;
            window.opener.__doPostBack();
                window.close();
        }

window.opener.__doPostBack error and Even if i have window.Close() function Popup window is not closing.

Upvotes: 0

Views: 117

Answers (1)

J.J.
J.J.

Reputation: 1118

One option would be a Session variable.

function GetRowValue(val) {

    var uniqueKey = window.opener.document.getElementById("UniqueKeyField").value;

    //ASP code here for assigning Javascript var to session var
    '<%Session["UniqueKey"] = "' + uniqueKey + '"; %>';
            window.close();
        }

Fetch variable with Javascript (if needed)

<script type="text/javascript">
    function GetUniqueKey()
    {
        var uniqueKey = '<%= Session["UniqueKey"] %>';
    }
</script>

Upvotes: 1

Related Questions