2010-01-19 74 views
1

處理ASP.NET Visual Studio 2008 C#。我有一個頁面。從這個頁面我需要調用一個彈出頁面。在彈出頁面上選定的值將在父頁文本控件上設置。將彈出窗口中的值傳遞給父窗體的文本框

  1. 一位家長頁面
  2. 的兒童頁。
  3. 以彈出的方式向孩子呼叫父母。
  4. 在彈出窗口中包含網格。
  5. 在彈出的網格上有命令選擇,點擊選擇關閉彈出窗口,選定的值將在父頁文本控件上設置。

我做的步驟1,2,3和4。但我需要完成一步沒有5.

回答

8

在父頁面:

<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" /> 

在子頁面:

<script type="text/javascript"> 
function f2() { 

    opener.document.getElementById("TextBox1").value = "hello world"; 
} 
</script> 
<input type="button" value="return hello world" onclick="f2();" /> 

此外,您可以將要從子頁面填充的控件的ID作爲GET參數傳遞給:

window.open("child.aspx?controlID=<%=TextBox1.ClientID %>"); 
相關問題