使用ASP.NET Visual Studio 2008 C#.我有一个页面.从这个页面我需要在弹出窗口上调用一个页面.在弹出页面上,将在父页面文本控件上设置选定值.
- 一个父页面
- 一个子页面.
- 将父对象调用为弹出窗口.
- 在弹出窗口中包含一个网格.
- 在弹出网格上有命令选择,单击选择关闭弹出窗口,选择的值将在父页面文本控件上设置.
我已经完成了步骤1,2,3和4.但我需要完成第5步.
在父页面上:
<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" />
Run Code Online (Sandbox Code Playgroud)
在子页面上:
<script type="text/javascript">
function f2() {
opener.document.getElementById("TextBox1").value = "hello world";
}
</script>
<input type="button" value="return hello world" onclick="f2();" />
Run Code Online (Sandbox Code Playgroud)
您还可以将要从子页面填充的控件ID作为GET参数传递:
window.open("child.aspx?controlID=<%=TextBox1.ClientID %>");
Run Code Online (Sandbox Code Playgroud)