从弹出窗口传递价值父窗体的文本框 [英] Passing value from popup window to parent form's TextBox
本文介绍了从弹出窗口传递价值父窗体的文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在ASP.NET Visual Studio 2008的C#工作。我有一个页面。在该页面中我需要调用弹出一个页面。在弹出的页面中选择的值将父页文本控件进行设置。
- 一位家长页
- 一个子页面。
- 呼叫父母和孩子之间的弹出窗口。
- 在弹出的窗口中包含一个网格。
- 在弹出的网格有命令选择,点击选择关闭弹出窗口和选择的值将在父页面文本控件设置。
块引用>我做的步骤1,2,3和4。但我需要完成5号的一步。
解决方案在父页面:
<脚本类型=文/ JavaScript的>
函数f1(){
window.open(child.aspx);
}
< / SCRIPT>
< ASP:文本框ID =TextBox1的=服务器>< / ASP:文本框><输入类型=按钮的onclick =F1();值=弹出/>在子页面:
<脚本类型=文/ JavaScript的>
函数f2(){ 。opener.document.getElementById(TextBox1中)值=Hello World的;
}
< / SCRIPT>
<输入类型=按钮值=重返世界你好的onclick =F2(); />您也可以通过您想从子页面填写为GET参数控制的ID:
window.open(child.aspx控件ID =<%= TextBox1.ClientID%GT;);
Work on ASP.NET Visual Studio 2008 C#. I have a page. From this page I need to call a page on popup. On the popup page selected value will be set on the parent page text control.
- One parent page
- One child page.
- Call parent to child as popup.
- On popup window contain a grid.
- On popup grid have command select,click on select close popup and selected value will set on parent page text control.
I have done steps 1,2,3 and 4. But I need to complete step no 5.
解决方案On parent page:
<script type="text/javascript"> function f1() { window.open("child.aspx"); } </script> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><input type="button" onclick="f1();" value="pop up" />
On child page:
<script type="text/javascript"> function f2() { opener.document.getElementById("TextBox1").value = "hello world"; } </script> <input type="button" value="return hello world" onclick="f2();" />
Also you can pass ID of control which you want fill from child page as GET parameter:
window.open("child.aspx?controlID=<%=TextBox1.ClientID %>");
这篇关于从弹出窗口传递价值父窗体的文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文