![](/img/trans.png)
[英]Passing data from parent window to popup(child) window in ASP.NET MVC 4 View
[英]passing values from popup window to parent window
我創建了一個帶有按鈕的頁面(creation.aspx)。 當我單擊按鈕時,將在新的瀏覽器窗口中打開一個彈出頁面(pass.aspx)。 然后在彈出窗口中進行一些操作,然后在彈出窗口中單擊“提交”按鈕。但是我有一個疑問。 我想將值從彈出窗口轉移到父窗口。
是否有可能。 如果可能的話,該怎么做? 請幫助我解決此問題。
在父頁面中:
<asp:ImageButton ID="img_pass" style="vertical-align:bottom;" runat="server" OnClientClick= "window.open('pass.aspx','','location=0,resizable=0,ScrollBars=1,statusbar=1,width=550,height=550,left=20,top=10,moveable=0') ;return false;" ImageUrl="~/images/bnt_pass.png" Width="20px" Height="20px" />
在彈出窗口中:
Response.Redirect("creation.aspx?id =" + value1.Text + "&" + value.Text);
string redirectUrl = "creation.aspx?id =" + value1.Text + "&" + value.Text;
ScriptManager.RegisterStartupScript(this, GetType(), "Redirect", "window.parent.location = " + redirectUrl , true);
使用Session
變量將值從一頁傳遞到另一頁。 (IE)保存您需要值Session[""]
在彈出頁面的服務器端事件(buttonclick,dropdownchanged等)變量和利用的Session[""]
在父頁面的變量。
您可以使用以下JavaScript代碼將值返回到父窗口。
函數fnOk(){
top.returnValue = "Data";
window.close();
return true;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.