子窗体是作为新开的弹出式窗体,操作完成后希望将该新窗体关闭,并回到原来的窗体上并更新原来页面上的信息,请教一下,应该怎么操作?

解决方案 »

  1.   

    我在新开窗体时是这样写的
    Response.Write("<script>window.open('aaa.aspx','www','height=200,width=400,top=0,left=0,toolbar=no,menubar=no,scrollbars=no, resizable=no,location=no, status=no');</script>");
      

  2.   

    我现在在aaa.aspx上操作完了之后就回到原来的页面,同时关闭aaa.aspx
      

  3.   

    //aaa.aspx:
    opener.location.reload();
    this.close();
      

  4.   

    建议你可以用全局变量,在弹出窗体中给相应的变量赋值。关闭后在父窗体中读取全局变量的值。
    关键是,你在父窗体中读取的时候一定要把代码段放在 子窗体.ShowDialog();之后。
      

  5.   

    以上两中情况分别使用于 web程序和winform程序
      

  6.   

    <script language=javascript>
    window.opener.location.reload(); //或refresh()
    window.close();
    </script>
      

  7.   

    private void button2_Click(object sender, EventArgs e)
            {
                using (Form5 f5= new Form5())
                {
                    f5.ShowDialog();
                   .....这里的代码我忘了.
               
                
                };
            }
      

  8.   

    我给一个DEMO
    可能编不过去
    父窗体
    private string m_strText;  //用来储存返回的String
    Public void SetFormat(string strText) //用来处理你想作的更新操作
    {
     this.m_strText=strText;
    }
    private void OpenChildWindow()// 打开子窗体 
    {
      frmChild frm=new frmChild();
      frm.setParentWindow(this);
      frm.ShowDialog();
    }子窗体:
    private frmParent m_frmParent;
    public void setParentWindow( frmParent frm)//获得父窗体实例
    {
      this.m_frmParent=frm;
    }
    private void frmChild_close()
    {
        this.m_frmParent.SetFormat(string strText);
    }
    你看看能用不?
      

  9.   

    给你个源码
    http://www.mikecat.net/threadview.asp?forumID=9&threadID=41 里边有个例子。
    不怕是病毒的话直接下载这个:http://www.mikecat.net/mikeapp/MikeCat_popvalue.rar
      

  10.   

    在子窗体中设个public的变量,关闭窗口后,主窗体仍可以访问这个变量的。
      

  11.   

    你需要用隐藏的input来进行传值,然后在js中打开模式窗口,然后进行显示,返回值先存放到input中,并进行提交;在page_load事件中进行判断input中的值,然后进行处理显示。
      

  12.   

    给一个例子给你,我在VS中有两个窗体,下面这个方法就是传子窗体的内容给父窗体.
                Form2 form2 = new Form2();
                form2.ShowDialog();
                if (form2.DialogResult == DialogResult.OK)
                    MessageBox.Show(form2.textBox1.Text);
      

  13.   

    不对吧,还不知道楼主问的是webform还是winform,就答这么多.
    不过都有答案了,我就不多次一举了.哈哈;)
      

  14.   

    在Web中使用session变量
    在WindowsForm中使用委托
      

  15.   

    谢谢各位的关注,我做的是b/s的.还是不太明白webform的要怎么用模式窗体?
      

  16.   

    Sample code as follows:-----java script------
    function OpenWin()
    {
    var strTemp = window.showModalDialog( 'yourUrl','dialogWidth=200px,dialogHeight=80px;' );
    if(strTemp != null) 
    {
    document.yourForm.txtHidden.value=strTemp;
    document.yourForm.submit();
    }
    } -----in your form aspx-----
    <INPUT id="txtHidden" type="hidden" name="txtHidden" runat="server"> -----in your form cs------
    if( this.IsPostBack )
    {
    if( txtHidden.Value != "" )
    {
                 //Do what you want here
     
                 txtHidden.Value = ""; //Clear data 
    }
    }