在asp.net中有两个页面:a.aspx和b.aspx。在a.aspx页面中有一个textbox(tb_reader)和一个button控件。当点击button按钮时进入b.aspx页面用来选取值。当点击b.aspx中的确定按钮时,选中的值(depart)就传到a.aspx中的textbox中。也就是:tb_reader.Text=depart的值。这应当如何来实现呢?高手帮忙啊!!!!!

解决方案 »

  1.   

    在父窗口a.aspx中open
    在子窗口b.aspx中opener
      

  2.   

    session 不可以。因为我想要两次用到a.aspx
      

  3.   

    smalling可以给我一个例子吗?谢谢!!
      

  4.   

    还有补充一点就是当点击了b.aspx中的确定后关闭b这时值就直接传到a中。
      

  5.   

    网上转的
    方法一:使用showModalDialog方法新建文件lyh.html
    输入 <!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>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title></title>
    </head><body>
    <input type="button" onclick="show('lyhshow.html')" value="弹出窗口"><br><br><br>返回值:
    <input type="text" id="returnvalue"><script language="javascript">
    function show(math)
    {
    var val= showModalDialog(math,"true", "dialogWidth:300px;dialogHeight:250px;status:no;help:no;");
    if(!val)
    {
    return;
    }
    else
    {
    document.all.returnvalue.value=val;
    }
    }
    </script>
    </body>
    </html>
    新建文件lyhshow.html
    输入
    <!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>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>来自Eric空间</title>
    </head><body>
    请输入:<input type="text" id="txtValue" value=""><br><br><br>
    <input type="button" onclick="ReturnValue()" value="返回输入值"><script language="javascript">
    function ReturnValue()
    {
    window.returnValue=document.all.txtValue.value;
    window.close();
    }
    </script>
    </body>
    </html>方法二:用window.open弹出窗口新建文件lyh2.html
    输入
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>来自Eric空间</title>
    </head><body>
    <input type="button" onclick="show('lyhshow2.html')" value="弹出窗口"><br><br><br>返回值:
    <input type="text" id="returnvalue"><script language="javascript">
    <!-- 
    function show(math)
    {window.open (math,'newwindow','height=250,width=300,top=300,left=300,toolbar=no,menubar=no,scrollbars=no, resizable=no,location=no, status=no') 
    //写成一行 }
    --> 
    </script>
    </body>
    </html>
    新建文件lyhshow2.html
    输入<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title></title>
    </head><body>
    请输入:<input type="text" id="txtValue" value=""><br><br><br>
    <input type="button" onclick="ReturnValue()" value="返回输入值"><script language="javascript">
    function ReturnValue()
    {
    window.opener.document.all.returnvalue.value=document.all.txtValue.value;
    window.close();
    }
    </script>
    </body>
    </html>
      

  6.   

    手写的,还是热的!
    tt.html:
    <html>
    <head></head>
    <body>
    <script>
    function test()
    {
       window.open('pp.html');
    }
    </script>
    <input type='text' id='tt_t'>
    <input type='button' value='button' onclick='test()'>
    </body>
    </html>
    ------------------------------------------------------------------
    pp.html:
    <html>
    <head></head>
    <script>
      function c()
      { 
         window.opener.document.getElementById('tt_t').value=document.getElementById('pp_t').value;
         window.close();
      }
    </script>
    <body>
    <input id='pp_t' type='text'><input type='button' value='button' onclick='c()'>
    </body>
    </html>
      

  7.   

    在MSDN中找跨页面传值,都是你要的东西。PriviousPage....
      

  8.   

    在ASP.NET高级编程2.0 (Wrox)也讲到这方面的内容。
      

  9.   

    在前台查出你选中行的第六列的值。
        function ADD()
        {
            var index = <%=this.GridItems.SelectedIndex%>;//取子窗体控件选中的索引
            var text = document.getElementById("GridItems").rows[index + 1].cells[1].innerText;
                                                    window.opener.document.form1.txtCoRe.value = text;
                                          
            window.close(); 
        } 这是我以前做开发的时候写的一个单击父窗体BUTTON弹出子窗体,取子窗体Gridview我选择的那一行的第一列的值,点确定然后关闭子窗体,然后返回给父窗体的txtCoRe文本框.
      

  10.   

    非常感谢大家,可是这些方法在.aspx中不能用啊!我还是没有做出来!
      

  11.   

    可是这些方法在.aspx中不能用啊! ???
    =====================================
    俺就比较纳闷?还请lz说说怎么个不能用法?
      

  12.   

    上面大多都是JS语言,在aspx中不能用?
    LZ说说怎么不能用啊
      

  13.   

    非常感谢大家,可是这些方法在.aspx中不能用啊!我还是没有做出来!?????
    ------------------------------------
    js语言怎么可能在aspx中不能用呢,建义你还是多多去看js语言吧
      

  14.   

    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>父页面</title>
    <script language="javascript" type="text/javascript">
    // <!CDATA[function bt_set_onclick() {
    window.open("bb.aspx");
    }// ]]>
    </script>
    </head>
    <body style="text-align: center">
        <form id="form1" runat="server">
        <div>
            <input id="aa" name="name" type="text" /><br />
            <br />
            <input id="bt_set" type="button" value="button" onclick="return bt_set_onclick()" />&nbsp;</div>
        </form>
    </body>
    </html>
    上面的是页面aa.aspx的代码
    下面是bb.aspx的代码:
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>子页面</title>
    <script language="javascript" type="text/javascript">
    // <!CDATA[function bt_up_onclick() {
    window.opener.document.form1.getElementById('aa').value=document.getElementById('bb').value;}// ]]>
    </script>
    </head>
    <body style="text-align: center">
        <form id="form1" runat="server">
        <div>
            <br />
            <br />
            &nbsp;
            <input id="bb" name="depart" type="text" />
            <input id="bt_up" type="button" value="button" onclick="return bt_up_onclick()" /></div>
        </form>
    </body>
    </html>
    高手帮我看一下我写的对不对??
      

  15.   

    哦,我没有写window.close();为何就错了呢?
    我现在加上了上面的话然后就对了!
    谢谢各位,我是要多看看JS语言!!
      

  16.   

    为什么在bb.aspx中用到提交的控件时就出错,而用到html中的提交按钮就对呢??
      

  17.   

    用session完全可以解决!为什么2次用a.aspx就不能用Session?我没想明白,你只不过是1次取值的过程而已
      

  18.   

    session如果可以的话我就用了,可是里面存在一个先后的问题。不是session的问题!
      

  19.   

    为什么在bb.aspx中用到提交的控件时就出错,而用到html中的提交按钮就对呢??
    ------------------------------------------------------------------------------
    有这种事?怪异!
      

  20.   

    是的啊,我也没有想通,后来我就用的html中的提交按钮,一用控件就提示:没有符合的操作!