模型视图控制器 - 如何将数据从子窗口 (mvc) 传递到父窗口



如何将数据从子窗口(mvc)传递到父窗口?几秒钟前|链接

我遇到需要将一些数据从子 (MVC) 页面传递到父窗口的情况。但在这种情况下,用户不需要与子窗口进行任何交互。子窗口将简单地通过按钮单击从父窗口打开,以运行服务器端进程并将一些代码值返回到父窗口,并且需要关闭。

我不确定如何将数据从 mvc 页面控制器传递到父页面以及如何关闭子窗口本身。

有什么建议吗?

我认为这可能会回答你的问题:

父窗口 - 父窗口.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>

儿童窗 - 儿童.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>

最新更新