各位大侠,你好! 
问题是这样的,在a页面中有许多个文本框,有一个选择按钮,当你单击这个选择按钮后,打开b页面,假如说b页面里有一个table(有很多行数据),当单击这个table的某一行后,这个行的中的部分数据会自动回填到a页面相应的文本框中,且b页面自动关闭,像这样的问题,该如何实现? 
请各位大侠给予指点,谢谢!比如,a页面中有textbox1、textbox2、textbox3、textbox4、一个button 这4个控件,textbox1的值是手工输入的,textbox2、textbox3、textbox4都是从b页面带过来的。这里好像有个刷新问题。
哪位能够给个实例代码?我用的语言为asp.net (c#)

解决方案 »

  1.   

    使用window.showModalDialog打开b页面,在本页面通过js给啊页面的控件赋值
      

  2.   

    A页面js<head id="Head1" runat="server">
        <title>无标题页</title>
         <script  language="javascript" type="text/javascript">
    function manage(){
    var hdc=window.open('receiver.aspx','','width=900,height=500');
    width=screen.width;
    height=screen.height;
    hdc.moveTo((width-900)/2,(height-500)/2);
    }
    }
    </script>
    body中的代码:
    <input id="Button11" style="width: 34px; z-index: 126; left: 815px; position: absolute; top: 127px;" type="button" value="..." onclick="manage()"/>
    可以弹出b面。b面中:cs文件:
     protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
             if(e.Row.RowType == DataControlRowType.DataRow) 
            { 
              //e.Row.Attributes.Add("onclick", "cc('" + e.Row.Cells[0].Text + "','" + e.Row.Cells[1].Text + "')");
                e.Row.Attributes.Add("onclick", "javascript:opener.location.href='tuodan.aspx?id=" + e.Row.Cells[0].Text.ToString() + "';window.close();");
            } 
        } 可以探出a面
    之后在a面接受 protected void Page_Load(object sender, EventArgs e)
        {
           
            if (!IsPostBack)
            {
                string idvalue1 = Request.QueryString["id"];
                TextBox24.Text = idvalue1;
            }
        }以上是可以的。但是a面的TextBox20为手工输入的,每次回到a面,他就被清空。请老大直接给个指点。
      

  3.   

    与TextBox20类似的还有大概20多个其它控件
      

  4.   

    你这样肯定会被清空,你从新执行了a页面,使用模态窗口
    window.showModalDialog('b.aspx',window, 'dialogWidth=800px;dialogHeight=500px;center=1;');b页面js
    $(window.dialogArguments.document.forms[0]).find("#TextBox24").val('选中的值');
      

  5.   

    这样的问题,网上的例子很多吧ASP.NET跨页面传值技巧总结http://apps.hi.baidu.com/share/detail/1061363ASP.NET跨页面传值技巧http://wenku.baidu.com/view/0d63be5177232f60ddcca10f.html
      

  6.   

     
    var s="";        
    var c="";        
    var f = window.opener;                
    var f1=document.Form1;        for(i=0;i<f1.selesort.options.length;i++)     
    {
    s=s+document.Form1.selesort.options[i].text
    c=c+document.Form1.selesort.options[i].value     
    }  
    if ( f != null )  
    {     
    window.close();     
    f.Form1.WXP_Name.value=s;     
    f.Form1.wxp_id.value=c;     f.Form1.TypeTxt.value=document.Form1.DangerName.value;  
    }
      

  7.   

    <form action="b.aspx" target="_blank">
      

  8.   

    在B页面添加onlick事件,参数通过?传递个A页面,在关闭B页面,
    在A页面加载的时候判断querystring的值,填充A页面
      

  9.   

    这个问题很简单, 就是一个父页面和子页面的传值问题。
    把下面代码复制 txt里 然后修改后缀为html  a页面
    <HTML> 
    <HEAD> 
    <TITLE> Window 1 </TITLE> 
    </HEAD> 
      
    <BODY> 
    <H1>Window 1</H1> 
    <INPUT TYPE="text" NAME="" runat ="server"><INPUT TYPE="submit"> 
      
    <script> 
    var aInput = document.getElementsByTagName("input"); 
    for (i = 0 ; i < aInput.length ; i++ ) 

    if (aInput[i].getAttribute("type") == "text") var textboxA = new Object(aInput[i]); 
    if (aInput[i].getAttribute("type") == "submit") var btnA = new Object(aInput[i]); 
    } // 这里把html里的2个标签定义出来,让行为层和结构层分离的更彻底 
      
    btnA.onclick = function() 

    window.open('b.html','newwindow','height=200,width=400') 
    } //使用window.open方法弹出窗口;此方法适用于各种浏览器 
    </script> 
    </BODY> 
    </HTML>
      

  10.   

    ------------------b页面   给多少金  我手把手告诉 呵呵  
    <HTML> 
    <HEAD> 
    <TITLE> New Document </TITLE> 
    </HEAD> 
      
    <BODY> 
    <H1>Window 2</H1> 
    <INPUT TYPE="text" NAME="" value="11" runat ="server"><INPUT TYPE="submit"> 
      
    <script> 
    var aInput = document.getElementsByTagName("input"); 
    for (i = 0 ; i < aInput.length ; i++ ) 

    if (aInput[i].getAttribute("type") == "text") var textboxB = new Object(aInput[i]); 
    if (aInput[i].getAttribute("type") == "submit") var btnB = new Object(aInput[i]); 

      
    btnB.onclick = function(){ 
    var sTextValue = textboxB.value 
    window.opener.textboxA.value = sTextValue 
    window.close(); 
    } //使用window.opener 方法获取父页面的对象,把子页面的值赋过去 
    </script> 
    </BODY> 
    </HTML>
      

  11.   

    http://topic.csdn.net/u/20091112/09/342769c1-0abf-4f92-8699-7ac7d462e0cf.html
      

  12.   

    用Session传值,b页面结束时刷新父页面,a页面加载时查看Session存不存在,取得数据后把这个Session丢掉
      

  13.   

    a叶面
    jsp:
    headfunction manage1(){
    var hdc1=window.showModalDialog('com.aspx',window, 'dialogWidth=800px;dialogHeight=500px;center=1;');
    body:
    body中的代码:
    <input id="Button11" style="width: 34px; z-index: 126; left: 815px; position: absolute; top: 127px;" type="button" value="..." onclick="manage()"/>cs文件中的代码:
     protected void Page_Load(object sender, EventArgs e)
        {
           
            if (!IsPostBack)
            {
                string idvalue1 = Request.QueryString["id"];
                TextBox24.Text = idvalue1;
            }
        }b叶面:
    aspx文件没动
    cs文件: protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {            if (e.Row.RowIndex == 0)
                {
                    Response.Write("" + e.Row.Cells[0].Text + "';");
                }
                Response.Write(" <script Language=JavaScript>");
                            //Response.Write("window.dialogArguments.document.form1.TextBox24.value ='" + e.Row.Cells[0].Text + "';");
        Response.Write("window.close();");
                Response.Write(" </script>");  
               
            }       }执行后,点击a中的button7后,系统没有探出叶面b,而是,textbox24自动更新(为gridview的最后一条数据的cell0),比如:在a中点击按钮01,没有探出窗口2,而是直接更新了窗口的数据,之后,如果 GridView1有3条数据,那末,传给a的数据为第三条哦。
      

  14.   

    RowDataBound里
    e.Row.Attributes.Add("onDblClick", "javascript:window.opener.location.href='子窗体B.aspx?id="+e.Row.Cells[1].Text.ToString() + "';window.close();");  
    e.Row.Attributes.Add("onDblClick", "javascript:window.opener.documentById('txt').value='"+e.Row.Cells[1].Text.ToString() + "';window.close();");  
     
     
    function select() {  
      var url = "../a.aspx?ToId=PId&ToName=PName";  
      var mwidth = "400";  
      var mheight = "250";  
      var loc_x, loc_y;  
      if (window.navigator.appName.toLowerCase().indexOf("netscape") > -1) {  
      alert(mwidth); loc_x = parseInt((document.body.clientWidth - mwidth) / 2 + 200);  
      loc_y = parseInt((document.body.clientHeight - mheight) / 2);  
      window.open(url, "", "left=" + loc_x + "px,top=" + loc_y + "px,width=" + mwidth + "px,height=" + mheight + "px,resizable=no,scrollbars=yes,status=0");  
      }  
      else {  
        
      loc_x = document.body.scrollLeft + event.clientX - event.offsetX - 100;  
      loc_y = document.body.scrollTop + event.clientY - event.offsetY + 170;  
      window.open(url, "", "left=" + loc_x + "px,top=" + loc_y + "px,width=" + mwidth + "px,height=" + mheight + "px,resizable=no,scrollbars=yes,status=0");  
      //indow.showModalDialog(url, self, "edge:raised;scroll:1;status:0;help:0;resizable:0;dialogWidth:" + mwidth + "px;dialogHeight:" + mheight + "px;dialogTop:" + loc_y + "px;dialogLeft:" + loc_x + "px");  
      }  
      }  
    a.aspx  
    var p_window;  
      if (window.navigator.appName.toLowerCase().indexOf("netscape") > -1)  
      p_window = window.parent.opener;  
      else  
      p_window = window.parent.opener;    function SetValue(id, name) {  
      p_window.document.getElementById("hf_Id").value = id;  
      p_window.document.getElementById("txtName").value =name;  
      self.close();  
      }
      

  15.   

    .....
    这问题还没搞定?
    ...............
     我也来点一下..
    -----------------------------------------
    a.aspx 页面打开b.aspx 页面连接传递个值 如: 
                           window.open("b.aspx?id=txt") //txt 需要接受值的textbox 控件id
    b.aspx 页面点击按钮传递值回a.aspx对应控件。
    javascript 代码:
    window.opener.document.getElementById("txt").value=yourValue;
    window.close();
    如果代码写在后台 cs 文件中  就需要加转义字符哦 如 (\"txt\").value
    这样 a.aspx 就能收到子窗口传过来的值了.
      

  16.   

    实在不行的话用session,将各控件的值赋给一个session,各控件的值用逗号分隔
      

  17.   

    这个问题很简单,你可以用ajax里的弹出试 panel对话框来做,在这个panel上写上你所有的table,其实就是避免了跳出一个新叶面的方式。更直接,而且panel可以根据你的需要随时关闭