.net中子窗体的值如何回传给父窗体的文本框

解决方案 »

  1.   

    不是非常懂你的意思父体调用子体类 子体=new 子体类
    子体.显示方法子体.属性="想要的值"父体.文本框=子体.属性是这个意思吗
      

  2.   

    classP:父类
    classC:子类
    在父类中
     classC child = new classC(this)
    child.show();在子类中的构造函数中可以自定义
    classP p;
    public classC(classP parent)
    {}然后你就可以随便用父窗体的东西了.设定父窗体的文本框还不简单
      

  3.   

    写的一个例子其主要的方法就是在子窗体中点回传时写一段JS脚本  opener.document.getElementById('txtProductName').value = document.getElementById('txtCondition').value;<!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>无标题页</title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <input id="Button1" type="button" value="高级查询"  onclick="window.open('Test_B.aspx','newwindow','width=300px,height=100px,top=300px,left=300px')"/>
            <asp:TextBox ID="txtProductName" runat="server" Text=""></asp:TextBox>
            <asp:Button ID="btnSearch" runat="server" Text="查询" OnClick="btnSearch_Click" />
            <asp:GridView ID="objGridView" runat="server">
            </asp:GridView>
            <asp:TextBox ID="txtParent" runat="server" Text = "aaa"></asp:TextBox>
            <input id="Button2" type="button" value="父窗体传值给子窗体"  onclick="window.open('Test_B.aspx','newwindow','width=300px,height=100px,top=300px,left=300px')"/>
        </div>
        </form>
    </body>
    </html><html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>无标题页</title>
        
    <script language="javascript" type="text/javascript">
    <!--function window_onload() {
        document.getElementById("txtChildren").value = opener.document.getElementById("txtParent").value;
    }
    function setValue()
    {
        opener.document.getElementById('txtProductName').value = document.getElementById('txtCondition').value;
        opener.document.getElementById('btnSearch').click();
        self.close();
    }
    // -->
    </script>
    </head>
    <body language="javascript" onload="return window_onload()">
        <form id="form1" runat="server">
        <div>
            产品名称:<asp:TextBox ID="txtCondition" runat="server"></asp:TextBox>
            <asp:Button ID="btnSearch" runat="server" Text="查询" OnClientClick="opener.document.getElementById('txtProductName').value = document.getElementById('txtCondition').value;opener.document.getElementById('btnSearch').click();self.close();" />
            <input type="button" value="子窗体传回给交窗体值" onclick="setValue();" />
            <asp:TextBox ID="txtChildren" runat="server"></asp:TextBox>
        </div>
        </form>
    </body>
    </html>
      

  4.   

    parent.父窗体的方法(给父窗体的参数);
      

  5.   

    ((TextBox)this.MdiParent.Controls["textBox1"]).text = "";
      

  6.   


    1: 所有权法
    //Form1:
    //需要有一个公共的刷新方法
    public void Refresh_Method()
    {
    //...
    }
    //在调用Form2时,要把Form2的所有者设为Form1
    Form2 f2 = new Form2() ;
    f2.Owner = this;
    f2.ShowDialog() ;
    //Form2:
    //在需要对其调用者(父)刷新时
    Form1 f1 ;
    f1 = (Form1)this.Owner;
    f1.Refresh_Method() ;eg:Form1中的函数: public void DiaoYong(string str)
            {
                this.textBox1.Text =str;
            }private void button2_Click(object sender, EventArgs e)
            {            string str = this.textBox1.Text;
                Form2 f2 = new Form2(str);//在构造函数中,向子窗体传值。
                f2.Owner = this;
                f2.ShowDialog();
            }Form2中的函数: public Form2(string ss)
            {
                InitializeComponent();
                this.textBox1.Text = ss;       } private void button1_Click(object sender, EventArgs e)
            {
                string st = textBox1.Text;            Form1 f1;
                f1 = (Form1)this.Owner;
                f1.DiaoYong(st);          this.Close();
            }
      

  7.   

    window.opener.document.getElementById('控件ID').value=值
      

  8.   

    ===============
    太多了
    ===============
    ASP.NET
    function vv()
      {
           kv=window.showModalDialog("test2.aspx",window,"center:yes;status:no;scroll:no;help:no;dialogWidth=320px;dialogHeight=150px");
          
           /* 1
           var newoption=document.createElement("Option")
       newoption.text=kv;
       document.getElementById("ee").options.add(newoption);   
       */
       
       /*2*/
       var option=new Option(kv,kv);             
                   document.getElementById("ee").options.add(option);
      } function cc()
     {
     /*一种方案:子窗体直接给父窗体赋值,事件全部在子窗体中处理*/
       window.dialogArguments.document.Form1.Text1.value=document.getElementById('s2').value;     
        /* 正确赋值*/
          var newoption=window.dialogArguments.document.createElement("Option")
    newoption.text=document.getElementById('s2').value;
    window.dialogArguments.document.getElementById("ss").options.add(newoption);

    /*第二种方案:子窗体将值传回父窗体,由父窗体处理*/
    window.returnValue= document.getElementById('s2').value;
         
          window.close();
     }
     function vv()
     {        
        g_pop=new Popup({ contentType:1,isReloadOnClose:false,width:420, height:150 });
        g_pop.setContent("title","添加新标题");
        g_pop.setContent("contentUrl","test3.aspx");
        g_pop.build();
        g_pop.show();    

        
     }