zdf2000

  博客园 :: 首页 :: 新随笔 :: 联系 :: 订阅 :: 管理 ::

在两个页面之间互相写其控件内的值

定义A页面,定义TextBox id="TextBox1"和Button id="Button1"
后台代码:

private   void  Page_Load( object  sender, System.EventArgs e)
        
{
            
this .Button1.Attributes.Add( " onclick " , " window.open('SelectData.aspx?rec=TextBox1','newwin','toolbar=no,menubar=no,status=no,location=no,resizable=no,scrollbars=no,width=218,height=185,top=190,left=300');return false; " );
        }

定义界面B:  TextBox id="TextBox1"和Button id="Button1" 和type="hidden" id="name"
脚本:

< SCRIPT language = " JavaScript " >
            
var  parwindow;
            parwindow
= self.opener;
            
var  recv  =  document.all( " name " ).value;
            
if  (parwindow  !=   null
            
{
            document.all(
" TextBox1 " ).value = parwindow.document.all(recv).value;
            }

            
            
function  changetext() 
            
{
                
if  (parwindow  !=   null
                
{
                    
try {
                            parwindow.document.all(recv).value 
=  document.all( " TextBox1 " ).value;
                        }

                    
catch (e)
                        
{
                        }

                 }

            }

        
</ SCRIPT >

 

放在form后
后台代码:

private   void  Page_Load( object  sender, System.EventArgs e)
        
{
            name.Value 
=  Request.QueryString[ 0 ];
            
this .Button1.Attributes.Add( " onclick " , " changetext();window.close() " );
        }
posted on 2006-03-27 09:21  透明_人  阅读(132)  评论(0)    收藏  举报