ASP.NET WEB FORM 子父窗体之间参数的传递
两个PAGE的代码如下:
page.aspx(父窗体)
<html>
<body>
<script language="C#" runat="server">
</script>
<form id="Form1" method=post runat="server">
<asp:TextBox ID=txtName Runat=server></asp:TextBox>
<input type=button value="弹出子窗口" onclick="Mywin=window.open('subpage.aspx');">
</form>
</body>
</html>
![](/Images/OutliningIndicators/None.gif)
subpage.aspx(子窗体)
<html>
<body>
<script language="JavaScript">
function popup()
{
window.opener.document.all["txtName"].value=document.all["txtSubName"].value;
window.close()
}
</script>
<script language="C#" runat="server">
</script>
<form id="Form1" method=post runat="server">
<asp:TextBox ID=txtSubName Runat=server></asp:TextBox>
<p><input type="button" value="传值并返回父窗口" name="button1" onclick="popup()"></p>
</form>
</body>
</html>
![](/Images/OutliningIndicators/None.gif)
几点说明:
1。弹出子窗体,将子窗体的textbox的值传递给父窗体
2。两个button都采用html控件,也可以换成asp.net 的server控件,至于server控件如何调用jscript,这里有个小窍门,button_click事件里执行这样的代码
string script="<script language="JavaScript">window.open('subpage.aspx');</script>"
Response.Write(script);
这样就执行了javascript代码
page.aspx(父窗体)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
subpage.aspx(子窗体)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
几点说明:
1。弹出子窗体,将子窗体的textbox的值传递给父窗体
2。两个button都采用html控件,也可以换成asp.net 的server控件,至于server控件如何调用jscript,这里有个小窍门,button_click事件里执行这样的代码
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
这样就执行了javascript代码