如何避免整个页面刷新值将值从弹出窗口传递到父级 [英] how to avoid entire page refreshment value passing value from popup to parent

查看:94
本文介绍了如何避免整个页面刷新值将值从弹出窗口传递到父级的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何避免整个页面刷新值将值从弹出窗口传递到父级
父页面---------

how to avoid entire page refreshment value passing value from popup to parent
parent page---------

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script language="Javascript" type="text/javascript">
       
    
        function sss() {
            var popup = window.open('pop.aspx', 'popup_id', 'scrollbars,resizable,width=300,height=400');
        }
        function test() {
            //Access the popup elements using this ID and fetch data from it
           
            var data = popup.document.getElementById('txtname').value;
            //document.frm.txt.value = data;
            alert(data);
            document.getElementById('txtid').value = data;
        }
    </script>
</head>
<body>
    <form id="form1" runat="server"><asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
    <div>
        
    </div>
       <asp:TextBox ID="txtid" runat="server"></asp:TextBox>
    <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" 
            onclientclick="sss()" />
        <asp:Button ID="btnSearchCriteria" runat="server" Text="Button" 
            onclientclick="test()" />
  </ContentTemplate>
    </asp:UpdatePanel>  </form>
</body>
</html>


弹出-----------


popup-----------

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="pop.aspx.cs" Inherits="pop" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script language="Javascript" type="text/javascript">
    function RefreshParentPage() {
       
       // window.opener.document.getElementById('txtid').value = document.getElementById('txtname').value;
        window.opener.document.getElementById('btnSearchCriteria').Click();
       
        window.close();
} 
</script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
         <asp:TextBox ID="txtname" runat="server"></asp:TextBox>
        <asp:Button ID="Button1" runat="server" 
            onclientclick="RefreshParentPage()" Text="Button" />

    </div>
    </form>
</body>
</html>



但它不起作用



but its not working

推荐答案

1.从基础页面(打开页面)中删除test()函数.
2.插入"return false;".作为sss()函数的最后一条语句.

希望它会有所帮助,如果有帮助,请将其标记为答案. :)
1. Remove the test() function from the base page (the opener page).
2. Insert "return false;" as the last statement of the sss() function.

Hope it helps, if helps please mark it as answer. :)


这篇关于如何避免整个页面刷新值将值从弹出窗口传递到父级的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆