HelloBD
HelloBD

Reputation: 387

Passing value from popup window to parent form's TextBox

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.

  1. One parent page
  2. One child page.
  3. Call parent to child as popup.
  4. On popup window contain a grid.
  5. 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.

Upvotes: 1

Views: 26700

Answers (1)

iburlakov
iburlakov

Reputation: 4232

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 %>");

Upvotes: 9

Related Questions