我们如何使用 JavaScript 将值从 PopUpWindow 传递到 Aspx 页面

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

本文关键字:Aspx 页面 PopUpWindow 何使用 JavaScript 我们      更新时间:2023-09-26

Im使用以下函数:

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

window.opener.__doPostBack error,即使我有window.Close()功能弹出窗口也不会关闭。

一个选项是会话变量。

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();
        }

使用 Javascript 获取变量(如果需要)

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