我在一个窗口中打开一个模式对话框,然后在模式对话框中的文本框中输入一段话,然后点击确定返回父窗口,请问我怎么才能在父窗口中得到那段话呢?

解决方案 »

  1.   

    子页面button调用的js方法
    function rtvalue()
    {
    top.returnValue="要返回的字符串";
    top.close();
    }
    父页面接受
    <script language=javascript>
    function test()
    {
    var r=window.showModalDialog("a.aspx",'','');
    document.getElementById('<%=TextBox1.ClientID%>').value=r;
    }
    </script>
      

  2.   

    不好意思,忘记说一下,我说的是WinForm编程,不是网页编程
      

  3.   

    dialog.ShowDialog();
    string content=dialog.textboxContent.Text;
      

  4.   

    我给一个DEMO
    可能编不过去
    父窗体
    private string m_strText;  //用来储存返回的String
    Public void SetText(string strText)
    {
     this.m_strText=strText;
    }
    private void OpenChildWindow()
    {
      frmChild frm=new frmChild();
      frm.ShowDialog();
      this.strText=frm.GetText();
    }子窗体:
    private string strText; //用来存储你要的字符串
    public string GetText()
    {
      Return strText;
    }
    你看看能用不?
      

  5.   

    子窗体定义一个public类型变量,
    frmChild frm=new frmChild();
      frm.ShowDialog();
    string s = frm.publicvariable;