问题描述:
a.aspx页面中使用Response.Write("<script language='javascript'>window.open('b.aspx', 'b', 'height=450, width=550, top=120, left=262, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no')</script>");创建个子页面。在子页面中通过一个DropDownList接受用户的选择,并想将用户选择的数据用一个变量传回a.aspx页面,并关闭b.aspx页面。传回a.aspx页面的值还要马上在a.aspx页面中的TextBox控件中显示出来。
我起初想用Session["B"]=“”传回a.aspx页面,之后刷新a.aspx页面,并关闭b.aspx页面,但是我在a.aspx页面中有对数据库的动态邦定,还有其他空间已经接受了用户的输入,这么一来原来的的a.aspx页面就重新down了一遍,全没了。
我初学这个,都不知道用什么做了,查了几个贴子,发现没有对口的。是不是用Ajax阿。我头都大了。请各位前辈帮小弟解决。送最后的80分。

解决方案 »

  1.   

    完全JS实现就可以了,给你看看htm页面代码。a.htm页面:
    <input id="text1" type="text" />
    <input type="button" value="open" onclick="window.open('b.htm', 'b', 'height=450, width=550, top=120, left=262, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no')"/>b.htm页面
    <script>
     function getText(){
       v = document.getElementById("textMe").value;
       objP = window.opener.document.getElementById("text1");
       objP.value = v;
       window.opener = null;
       window.close();
     }
    </script>
    输入值<input id="textMe" type="text" />
    <input type="button" value="把这里输入的值赋值给父窗口中的textbox" onclick="getText();"/>
      

  2.   

    BearRui(AK-47) ( ) 信誉:110  2007-08-17 10:18:44  得分: 0  
     
     
       完全JS实现就可以了,给你看看htm页面代码。a.htm页面:
    <input id="text1" type="text" />
    <input type="button" value="open" onclick="window.open('b.htm', 'b', 'height=450, width=550, top=120, left=262, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no')"/>b.htm页面
    <script>
     function getText(){
       v = document.getElementById("textMe").value;
       objP = window.opener.document.getElementById("text1");
       objP.value = v;
       window.opener = null;
       window.close();
     }
    </script>
    输入值<input id="textMe" type="text" />
    <input type="button" value="把这里输入的值赋值给父窗口中的textbox" onclick="getText();"/>  
     
    ---------
    同意
      

  3.   

    .aspx里面写:var returnValue = window.showModalDialog(URL,self,"edge:raised;scroll:0;status:0;help:0;resizable:1;dialogWidth:320px;dialogHeight:300px;");
    b.aspx:
    string mfstr = "<script>\n";
    mfstr += "window.returnValue='" + returnvalue.Replace("'", "\'") + "'\n";
    mfstr += "window.close()\n";
    mfstr += "</script>\n";
    这样就OK了
      

  4.   

    MasDn(欧总) ( ) 信誉:100 
    ------
    一起学
      

  5.   

    a.aspx
    <script>
    var txt = document.getElementById("xxx");
    </script>b.aspx
    提交后
    parent.txt = "aaa";
      

  6.   

    弹出层内返回数据
    http://www.aspxboy.com/private/showthread.asp?threadid=673弹出窗口内返回数据
    http://www.aspxboy.com/private/showthread.asp?threadid=623
      

  7.   

    A页面:-------------------------------
    html 
    <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
            <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
    *.cs----------------------------------------------
       protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["abc"] != null && Request.QueryString["abc"] != "")
            {
                TextBox1.Text = Request.QueryString["abc"];
            }
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            Response.Write("<script>window.open('B.aspx');</script>");
        }B页面:--------------------------
    <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />*.cs---------------
        protected void Button1_Click(object sender, EventArgs e)
        {
            Response.Write("<script>opener.location='A.aspx?abc=123';window.close();</script>");
        }
      

  8.   

    BearRui(AK-47) ( ) 信誉:110 
    --------------------
    我照着你说的做了,但是点击"把这里输入的值赋值给父窗口中的textbox"按钮时 没有反应,子窗口都没有关?
      

  9.   

    我照着你说的做了,但是点击"把这里输入的值赋值给父窗口中的textbox"按钮时 没有反应,子窗口都没有关?
    ----------------
    我这里测试过没问题,你可以把我的代码copy到2个htm文件中进行测试。在测试的时候注意要允许IE执行JS脚本(ie会弹出提示)
      

  10.   

    BearRui(AK-47) ( ) 信誉:110 
    -------------------
    我这里测试过没问题,你可以把我的代码copy到2个htm文件中进行测试。在测试的时候注意要允许IE执行JS脚本(ie会弹出提示)
    -----------------------------------------------------------------
    你说的我试了  正和我要求  ,我在往我的页面移,谢谢这么细心的帮助
    有希望了
      

  11.   

    我试着把这两个页面的语句放在两个.aspx页面中为什么 就不行了呢??  我考在来个.htm中就可以阿
      

  12.   

    b页面的button显示了,但是就是触发不了 ,点击没用?
      

  13.   

    主 
    function Showindow(str)
        {
            var obj2=new Object();
            obj2.name=str;       
            window.showModalDialog("House_Modify.aspx",obj2,"dialogWidth=650px;dialogHeight=500px");
            parent.document.location.reload();
        }
      

  14.   

    我试着把这两个页面的语句放在两个.aspx页面中为什么 就不行了呢?? 我考在来个.htm中就可以阿
    -------------------------
    看看是不是id什么的搞错了,因为服务器端控件生成成html控件后id有可能会变化。把你的代码贴出来看看。
      

  15.   


    终于解决了。我的子页面的JS是这样写的:
    <script>
    function getText(){
    obj= document.getElementById("DropDownList2");
    v = obj.options[obj.selectedIndex].value;
    objP = window.opener.document.getElementById("WithMusic");
    objP.innerHTML = v;//WithMusic是个Label,所以这么负值
    window.opener = null;
    window.close();
    }
    </script>
    <input id="butt" type="button" value="button" onclick="getText();">
    根据BearRui(AK-47) ( ) 信誉:110 大哥给的代码该得。
    终于实现我要实现的了,初学asp.net,而且学会了在网上查质料,问问题
    高兴死我了,可惜就是我的分数一分也没了。希望以后大家还要多多帮帮我这个初学者哦。