2014-04-05 210 views
0

如何將數據從子窗口(mvc)窗口傳遞給父窗口? 幾秒鐘前| LINK如何將數據從子(mvc)窗口傳遞到父窗口?

我有一種情況,我需要將一些數據從孩子(MVC)頁面傳遞給父窗口。但在這種情況下,用戶不需要與子窗口進行任何交互。子窗口將通過單擊按鈕從父級打開,以運行服務器端進程並將一些代碼值返回給父窗口並需要關閉。

我不確定如何從一個MVC頁面控制器傳遞數據給父頁面以及如何關閉子窗口本身..

有什麼建議?

回答

0

我想這可能會回答你的問題:

父窗口 - parent.asp

<html> 
<script language="javascript"> 
function openwindow() {  
    retval=window.showModalDialog("child.asp") 
    document.getElementById('passedChild').value=retval 
} 
</script> 
<body> 
<form name=frm> 
<input name="passedChild" id="passedChild" type=text> 
<input type=button onclick="javascript:openwindow()" value="Open Child"> 
</form> 
</body> 
</html> 

子窗口 - child.asp

<html> 
<head> 
<% 
    '... i work in classic asp so can run asp here and then flow into JS for retrun 
%> 
// 
<script language="javascript"> 
function changeparent() {  
    window.returnValue="passed value" 
    window.close() 
} 
</script> 
</head> 
<body> 
<form> 
<input type=button onclick="javascript:changeparent()" value="Change passedChild"> 
</form> 
</body> 
</html> 
相關問題