opener.document.getelementbyid,用这个方法可以吗,怎么用了,各位是否能给我实例。

解决方案 »

  1.   

    Form1类:
      textBox1:显示来自Form2的值
      button1:调出Form2窗口
      public string strval//传值与赋值属性
      {
        get{return this.textBox1.Text;}
        set{this.textBox1.Text = value;}
      }
      button1_Click事件:
        Form2 f2 = new Form2();
        f2.Owner = this;
        f2.ShowDialog();Form2类:
      textBox1:设置Form1中TextBox的值
      button1:赋值按钮
      button1_Click事件:
        Form1 f1 = (Form1)this.Owner;
        f1.strval = this.textBox1.Text;
      

  2.   

    txtID在父窗口中是个textboxResponse.Write(@"<script language='javascript'>"
                + "opener.document.all.txtID.value ='abc';"
                + "</script>");
      

  3.   

    传值 
    ParentPage.aspx: 
    window.showModalDialog("DialogPage.aspx?para1=aaa?2=bbb"); DialogPage.aspx: 
    string str1=Request.QueryString["para1"].toString(); 
    string str2=Request.QueryString["para2"].toString(); 返回值 
    DialogPage.aspx: 
    window.returnvalue="aaa"; ParentPage.aspx: 
    var str=window.showModalDialog("DialogPage.aspx");
      

  4.   

    谢谢chinasdp() 这个实例您已经实现了吗?f2.Owner = this;
    f2.ShowDialog();
    (Form1)this.Owner;Owner和ShowDialog没有Web程序里没有提供这两个属性和方法。您说的是win程序吗。对不起,我没说清楚,我做的是web程序。谢谢你。
      

  5.   

    ralpha08(被水淹死的鱼) 
       txtID在父窗口中是个textbox
    Response.Write(@"<script language='javascript'>"
                + "opener.document.all.txtID.value ='abc';"
                + "</script>");谢谢您,不很明白你的回复是什么意思,这句话写在哪儿,父窗口下,还是子窗口下。“txtID在父窗口中是个textbox”我已经按你的去做了。把这段程序写在了子窗口下,结果点按纽后,又弹出一个子窗口。另外:您这句话是依据什么给父窗口传值的,为什么这句话就确认就能传到父窗口呢。"opener.document.all.txtID.value ='abc';"仅仅依据这一行代码?谢谢
      
     
      

  6.   

    jc15271149(嘿咻)返回值 
    DialogPage.aspx: 
    window.returnvalue="aaa"; ParentPage.aspx: 
    var str=window.showModalDialog("DialogPage.aspx");您可以具体谈谈怎么接受子窗口的值吗。
    window.returnvalue="aaa"; 这句话写在哪儿。找不到window这个东西。用什么传
    按纽吗?按纽事件怎么写。
      

  7.   

    这段代码写在子窗口中 
    譬如可以写在一个Button的OnClick事件中这样点击这个Button的时候 父窗口的
    txtID的text属性就会是"abc"Response.Write(@"<script language='javascript'>"
                + "opener.document.all.txtID.value ='abc';"
                + "</script>")
      

  8.   

    ralpha08(被水淹死的鱼) 大哥,我实验了,不行。点这个按钮后又弹出一个新的子窗口。父窗口主要代码:
    protected System.Web.UI.WebControls.TextBox txtID;//此文本框接受由子窗口传入的值
    private void Button1_Click(object sender, System.EventArgs e)
    {
        string s="javascript: window.showModalDialog('WebForm2.aspx');";
        this.Button1.Attributes["onclick"]=s;//为什么总是慢半拍呢??
    }子窗口主要代码:
    protected System.Web.UI.WebControls.TextBox TextBox1;//此文本框写要传入父窗口的字符
    private void Button1_Click(object sender, System.EventArgs e)
    {
        Response.Write(@"<script language='javascript'>"
                + "opener.document.all.txtID.value ='abc';"
                + "</script>")
    }你看,这是两个页面的主要代码,可是还是不行。
      

  9.   

    父窗口主要代码改为:
    protected System.Web.UI.WebControls.TextBox txtID;//此文本框接受由子窗口传入的值
    private void Button1_Click(object sender, System.EventArgs e)
    {
       Response.Write(@"<script language='javascript'>"
                + "window.open('WebForm2.aspx','win','width=200,height=200');"
                + "</script>")
    }
      

  10.   

    ralpha08(被水淹死的鱼),谢谢你呀!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!真的搞定了。
      

  11.   

    也谢谢各位的关注。特别鸣谢ralpha08(被水淹死的鱼)。