js new Open window vaule send and receive get Problem

来源:互联网 发布:腾讯视频 mac 旧版本 编辑:程序博客网 时间:2024/05/16 06:15

    <script>
    function OpentryCustomer()
    {
   
    var Txttry = "<%= Txttry.ClientID %>";
    var Hitry = "<%= Hitry.ClientID  %>";
    var Apppath = "
http://localhost:58945/WebSite1/"
    var url = Apppath+"CustomerDialog.aspx?Userid="+Hitry+"&UserName="+Txttry+"";
   alert(url);
  window.open(url,'newwindows1','height=1000, width=700, top=10, left=10, toolbar=no, menubar=no, scrollbars=yes, resizable=yes,location=no, status=no');
    }
    </script>

 

<div>
   <asp:Button ID="BtnSearch" runat="server" Text="SearchTry"  OnClientClick="OpentryCustomer()" />
     <asp:Button ID="btnReSelectCustomer_Main" runat="server" CausesValidation="False" Visible="false"/>
   <asp:TextBox ID="Txttry" runat="server" Text="" />
   <asp:HiddenField ID="Hitry" runat="server" />
    </div>

 

另一个页面,

 

 

<script>
/* request类 */
function request(strParame) {
var args = new Object( );
var query = location.search.substring(1);
var pairs = query.split("&"); // Break at ampersand
for(var i = 0; i < pairs.length; i++) {
var pos = pairs[i].indexOf('=');
if (pos == -1) continue;
var argname = pairs[i].substring(0,pos);
var value = pairs[i].substring(pos+1);
value = decodeURIComponent(value);
args[argname] = value;
}
return args[strParame];
}
</script>
<script>
function SelectCustomer()
                {
                var userid = request('Userid');
                alert(userid);
                var username= request('UserName');
                alert(username);
               
                var customerID=document.getElementById("<%= TxtName.ClientID %>").value;
                alert(customerID);
                var customerName=document.getElementById("<%= TxtID.ClientID %>").value;
                alert(customerName);
                    if(window.opener!=null)
                    {
                        var id = window.opener.document.getElementById(userid);
                        alert(id);
                        if(id!=null)
                        {
                          id.value = customerID;
                        }
                        var customerNamCtrl = window.opener.document.getElementById(username);
                        alert(customerNamCtrl);

                            if(customerNamCtrl!=null)
                            {
                                customerNamCtrl.value = customerName;
                            }

                        window.close();
                    }
                    return false;
                }

</script>

</head>
<body>
    <form id="form1" runat="server">
    <div>
    <asp:Button ID="Btn" runat="server" OnClientClick="SelectCustomer()" />
    <asp:TextBox ID="TxtName" runat="server"  Text="shabi"/>
    <asp:TextBox ID="TxtID" runat="server" Text="shamao" />
    </div>

原创粉丝点击