A页面上有个文本框和一个按钮,点击按钮出现B页面,
B页面上具体的实现查询的功能,怎么将B页面上查询结果(某条记录)返回到A页面上的文本框内?
不考虑刷新不刷新的问题,方面的给个伪代码,急切等待,谢谢

解决方案 »

  1.   

    用javascript没问题,按B的时候弹出窗口进行查询,将选中的结果当做字符串传回A即可!代码较麻烦,让别人写吧!
      

  2.   


    function ReturnValue(ReturnParam)
    {
    window.returnValue=ReturnParam;
    window.close();
    }
    后台给每一行加上
    DataGrid2.Items[i].Attributes.Add("onclick","ReturnValue('"+ReturnParam+"')");
      

  3.   

    哦,对了,那个Function是前台页面的JavaScript
      

  4.   

    c#:
    string tmp = "abc";
    Response.Write("<script>opener.document.getElementById('TextBox1').value='"+tmp+"'; </script>";
      

  5.   

    用javascript,在A页写一段赋值脚本比如 function aa(arr)
    在b写一个脚本调用A页脚本 opener.aa(arr) arr就是你将在a显示的在b查到的结果
      

  6.   

    上面的代码适用于windown.open()打开的窗口,如果是模态窗口,则改为:
    string tmp = "abc";
    Response.Write("<script>parent.document.getElementById('TextBox1').value='"+tmp+"'; </script>";
      

  7.   

    这不就可以用AJAX做吗?  数据量大就用异步.. 小就用同步哈..(这个是不弹出页面的,B的这个页面只是实现一个查询功能,再response.write(Object 返回的结果.))如果一定要把B页面显示出来.. 可以用JS语言. 在A页面点击按键时 window.open("","","")里面给要弹出来的窗口命名..  再A页面里面的变量可以通边这个名字一步步的找到这页面里面的所有的控件的值. 只提供一个思路..代码可以从JS资源里找的.. 很多类似的..
      

  8.   

    A:<INPUT id="txtSendToID" type="hidden" name="txtSendToID" runat="server">Response.Write("<script>window.open('B');</script>"); B:java
    function AddChecked()
    {
    window.opener.document.forms[0].txtSendToID.value = selectUserID;
    window.close();
    }

      

  9.   

    A页面的javascript:
    var rt = openDialog(B.ASPX,'',620,400,'status:no;help:no');
     if (typeof(rt) != 'undefined') 
      {
        rt//B.ASPX的返回值
      } 
    B页面查询结果这样返回:Page.RegisterStartupScript("success","<script language=javascript> window.returnValue = '"+returnvalue+"'; alert('查询成功')</script>");
      

  10.   

    可以使用vs.net2.0自带的跨页面传值
    第一个页面:Button1,TextBox1
    事件:
    (1)page_load
     if (Page.PreviousPage != null)
            {
                TextBox t = (TextBox)PreviousPage.FindControl("TextBox1");
                if (t != null)
                {
                    TextBox1.Text = t.Text;
                }
                else
                {
                    Response.Write("Error");
                }
            }(2)Button1事件:Response.Redirect("default4.aspx");第二个页面:BUtton1,TextBox1
    设置Button1的PostBackUrl为第一个页面这样就可以将第二个页面的TextBox1的值传过去不知道是不是lz想要的
      

  11.   

    新标准里提倡这种写法 opener.document.getElementById(控件ID).value=
      

  12.   

    孟老大的:
    可以通过window.returnValue向打开对话框的窗口返回信息,当然也可以是对象。例如: test4.htm
     ===================
     <script>
      var a = window.showModalDialog("test5.htm")
      for(i=0;i<a.length;i++) alert(a[i])
     </script> test5.htm
     ===================
     <script>
     function sendTo()
     {
      var a=new Array("a","b")
      window.returnValue = a
      window.close()
     }
     </script>
     <body>
     <form>
      <input value="返回" type=button onclick="sendTo()">
     </form>
      

  13.   

    你可以在B页做查询,把查到的结果放到一个隐藏哉中,然后用上面的方法返回隐藏域的值就OK
    --把隐藏哉设为runat="server",在load事件中加载查询到的内容
      

  14.   

    a:
    window.open ....b
    window.opener.textbox.value=..;
    window.close();
      

  15.   

    首先在A.aspx页面里添加javascript
    <script language="javascript">
    <!--
              function openwin2()
    {
    var a=window.showModalDialog('b.aspx',window,'dialogWidth:300px;dialogHeight:180px;center:yes;help:no;resizable:no;status:no');
    if(a!=null)
    {
    document.all.textbox1.value=a;
    }
    }
    -->
    </script>再再B.aspx的代码里的选择记录事件里添加如下:
    Page.RegisterStartupScript("","<script language='javascript'>var a= new Array('"+/*选定或查询出的值*/+"');window.returnValue=a;window.close();</script>");
      

  16.   

    谢谢各位结帖了,Thank you for your help