.net模式子窗口传值给父窗口

来源:互联网 发布:国产芯片知乎 编辑:程序博客网 时间:2024/05/17 02:59

父窗口代码:

  <scritp type="text/javascript">

  function showChil() {

   window.showModelDialog("childre.aspx?pare=nn",window,"help:no;");

   window.location.href.reload();

 }

</script>

 

<asp:Button id='btn' text="子窗体" runat="server" onclick="showChil()"></asp:Button>

<asp:TextBox id='AllName' runat="server" />  //接受子窗口传来的值

 

 

chldre.aspx子窗口代码:

<asp:Button id="btnShow" runat="server" onclick="btnShow_click" />

<asp:TextBox id='txtName' runat="server" />

在.cs代码中

click代码事件中

 string names= this.txtName.Text;
        Response.Write("<script language='javascript'> opener.document.form1.AllName.value = '" + names + "' ;</script>");   //form1是父窗口中的form表单,AllName是父窗口中的接收文本框
        Response.Write("<script language='javascript'>window.close();</script>") ;

原创粉丝点击