例如,在A页面中有一个文本框tb_Dept_Id,一个标筌lbl_Dept_Name和一个按钮, 在单了按钮时, 弹出一个页面,该页面中是一个列表(共有两个栏位Dept_Id,Dept_Name), 当我双击列表中的项后,B窗口关闭, 并更改A页面中tb_Dept_Id和lbl_Detp_Name的Text属性为所选的项.
大家能不能帮给一个实例, 我自己弄好久了,都没搞出来.(分不够我再加)

解决方案 »

  1.   

    1 在主窗体上加上js
    function doResult(str1,str2){
    document.getElementById("txtkeywords1").value = str1;
    document.getElementById("txtkeywords2").value = str2;
    }
    2 加弹出窗口上加上js
    <script language="javascript">
    function onselect(val)
    {
    top.opener.doResult(val);
    top.window.close();
    }
    </script>3 在列表的绑定事件上加上这个
    private void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
    {
    if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
    {
    ((LinkButton)e.Item.FindControl("btnSelect")).Attributes.Add("onclick", "javascript:onselect("+e.Item.Cells[1].Text.Trim()+","+e.Item.Cells[1].Text.Trim()+");");

    }上面是参考,要作适当修改
    }
      

  2.   

    在一个页面上显示就可以了。那个显示出来的列表可以用使用了 runat="server"的div 的 visable来实现。
      

  3.   

    先弹出窗口
    onclick='window.showModalDialog("tanchu1.aspx?hwid=<%=hid.Value%>",window,"status:false;dialogWidth:500px;dialogHeight:500px;")'
    在tanchu1.aspx页面脚本
    function GetInfo(str,hid)   
    {   
        var arg = window.dialogArguments;   
        arg.SetTextBox(str,hid);//把值传送到原窗口SetTextBox方法里    
        window.close();     
    }   
    在原来的窗口中写上js方法SetTextBox(str,hid);    
    类似
    function SetTextBox(str,hids)   
    {   
      
        var id = '<%=this.yxml.ClientID %>';   
        document.getElementById(id).value = str;
        
        var hid = '<%=this.hid.ClientID %>';   
        document.getElementById(hid).value = hids;   
    }  
      

  4.   

    父页面中:这是一个js他的意思就是模拟一个页面生成。ReturnValue就是那一个页面返回的值
    function btnFileUplowe_onclick() { 
       //文件上传 
         ReturnValue=window.showModalDialog("../../FileUpdownControl.aspx?TheType=Ticket",window,"dialogWidth=550px;dialogHeight=300px;status=no;");  
         // 
         //var theReturnArr=ReturnValue.split("."); 
          
         document.getElementById("FileImgUpDown").value=ReturnValue; 
         
    }
    在上面的父页面中 非常重要就是就是showModalDialog  它表示弹出的不是一个页面。而是一个模拟的。不然是不能返回值的在这里方法中你们把 ReturnValue 弹出来就可以看见了 这个是一个新页面里面的js方法  RequestValue这个是一个特定函数。thevalue表示要返回的值,一定要记得 window.close();不然页面会弹出第三个页面。当然你的第二个页面需要你手动关闭。这也是没有办法的。暂时我还没有找到办法解决<script type="text/javascript"> 
        function RequestValue(thevalue) 
        { 
             
            window.returnValue=thevalue; 
            window.close(); 
        } 
     </script>
    还有的问题就是,在 模拟弹出的页面中,是不能返回服务器进行操作的。一操作就会弹出第三张页面。主意这个弹出的才是一个页面 而不是一个模拟的页面。所以在模拟弹出页面以后。我们只能在 Page_Load事件里面写相关的页面绑定的方法。而不能写相关的操作方法。这也是我遇见的一个难点。暂时没有解决。在前台的操作中。我们只能使用JS进行操作 这也是模拟弹出的页面的局限性。毕竟不是一个新页面以上代码在VS2005 测试成功
    选自:http://blog.csdn.net/jacky4955/archive/2008/12/09/3481837.aspx
      

  5.   

    thevalue 这个值 你需要在下列中赋值给他
     window.returnValue=xiala.selectValue;
      

  6.   

    大致和你一样的一个操作
    用模式窗口,主画面
    <script type="text/javascript" language="javascript">    
        function showwindow()
        {      
            var returnValue = window.showModalDialog("DItemList.aspx",
           'window','dialogWidth=650px;dialogHeight=420px;status=no');
           
           document.getElementById ("txtItem_id").value = returnValue == null?document.getElementById ("txtItem_id").value:returnValue;
        }
    </script>子画面grid里面,添加一个双击事件。
         #region 添加点击事件        /// <summary>
            /// 添加点击事件
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
            {
                try
                {
                    if (e.Row.RowType == DataControlRowType.DataRow)
                    {
                        string aa = "window.returnValue = \"" + e.Row.Cells[0].Text + "\";window.close();";
                        e.Row.Attributes.Add("ondblclick", aa);
                    }
                }
                catch (Exception ex)
                {
                    this.ShowMessage(ex.Message);
                }
            }        #endregion
      

  7.   


    试过你的方法,的确可行, 不过我如果是使用的asp.net的控件,该怎么实现?我的代码如下:
    a.aspx
    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="a.aspx.cs" Inherits="a" %><!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 runat="server">
        <title>a窗体</title>
        <script language="javascript" type="text/javascript">
            function doResult(str1, str2) {
                document.getElementById("tb_Dept_Id").value = str1;
                document.getElementById("tb_Dept_Name").value = str2;
            }
            function btn_Select_onclick() {
                window.open("b.aspx", "b窗体", "width=550,height=420,scrollbars=yes,resizable=yes,menubar=no,z-look=yes");
            }    </script>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
        Dept_Id"<input type="text" id="tb_Dept_Id" runat="server" /><br />
        Dept_Name:<input type="text" id="tb_Dept_Name" runat="server" /><br />
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" id="btn_Select" runat="server" value="选择" onclick="return btn_Select_onclick()" />
        </div>
        </form>
    </body>
    </html>
    b.aspx
    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="b.aspx.cs" Inherits="b" %><!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 runat="server">
        <title>b窗体</title>
        <script language="javascript" type="text/javascript">
            function onSelect(str1, str2) {
                top.opener.doResult(str1, str2);
                top.window.close();
            }
            function btn_Result_onclick() {
                onSelect(document.getElementById("tb_Dept_Id").value, document.getElementById("tb_Dept_Name").value);
            }    </script>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            Dept_Id"<input type="text" id="tb_Dept_Id" runat="server" /><br />
            Dept_Name:<input type="text" id="tb_Dept_Name" runat="server" /><br />
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input
                type="button" id="btn_Result" runat="server" value="返回" onclick="return btn_Result_onclick()" />
        </div>
        </form>
    </body>
    </html>
      

  8.   

    在同一页做不是很方便吗?用一个div模拟弹出的新窗口就可以了吧?
      

  9.   

    在A页面
    function OpenUpload(Id)
    {
    var url = "upload.aspx";
    win=window.open(url,"upload","width=600,height=450,left=0,top=0,scrollbars=1,status=0");
    win.focus();
    }
    function GetV(strCheckName)
    {
    var txt_b = window.document.getElementById("txtM");
    txt_b.value = strCheckName;
    }
    b.aspx         Response.Write("<script language='javascript'>window.opener.GetV('');</script>");
            Response.Write("<script language='javascript'>window.close();</script>");
    或JQUERY实现模式窗口,很方便
      

  10.   

    还是不要用Response.Write像前台输出脚本的比较好,看LZ的代码Button明显用的是HTML控件啊,直接onclick=""就行了。如果是服务器控件只只需加OnClientClick=""就好了
      

  11.   


    我是说TextBox用的asp.net控件该怎么实现??