模态窗口(showModelessDialog),如何给父页面传值
我现在在我的父页面要接受模态窗口传过来的值。。请问一下,我弹出来的模态窗口如何给父页面传值,我的父页面如何接受模态窗口传过来的值?
help
--------------------编程问答-------------------- protected void btn_select_Click(object sender, EventArgs e)
{
if (this.drop_user.SelectedValue != "null")
{
string dd = this.drop_user.SelectedValue.Trim();
Response.Write("<script Language=JavaScript>");
Response.Write("window.opener.document.forms['form1'].elements['username'].value='" + dd + "';");
Response.Write("window.close();");
Response.Write("</script>");
}
} --------------------编程问答-------------------- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>Parent Webform</title>
<script language="javascript">
function OpenChild()
{
var ParmA = retvalA.value;
var ParmB = retvalB.value;
var ParmC = retvalC.value;
var MyArgs = new Array(ParmA, ParmB, ParmC);
var WinSettings = "center:yes;resizable:no;dialogHeight:300px"
//ALTER BELOW LINE - supply correct URL for Child Form
var MyArgs = window.showModalDialog("ChildWebForm.htm", MyArgs, WinSettings);
if (MyArgs == null)
{
window.alert("Nothing returned from child. No changes made to input boxes")
}
else
{
retvalA.value=MyArgs[0].toString();
retvalB.value=MyArgs[1].toString();
retvalC.value=MyArgs[2].toString();
}
}
</script>
</HEAD>
<body>
<P><INPUT id="retvalA" type="text" value="AAA"></P>
<P><INPUT id="retvalB" type="text" value="BBB"></P>
<P><INPUT id="retvalC" type="text" value="CCC"></P>
<P><BUTTON onclick="OpenChild()" type="button">
Open Child Window</BUTTON>
</P>
</body>
</HTML>
--------------------编程问答-------------------- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Child Webform</TITLE>
<script language="javascript">
function Done() {
var ParmA = tbParamA.value;
var ParmB = tbParamB.value;
var ParmC = tbParamC.value;
var MyArgs = new Array(ParmA, ParmB, ParmC);
window.returnValue = MyArgs;
window.close();
}
function doInit() {
var ParmA = "Aparm";
var ParmB = "Bparm";
var ParmC = "Cparm";
var MyArgs = new Array(ParmA, ParmB, ParmC);
MyArgs = window.dialogArguments;
tbParamA.value = MyArgs[0].toString();
tbParamB.value = MyArgs[1].toString();
tbParamC.value = MyArgs[2].toString();
}
</script>
</HEAD>
<BODY onload="doInit()">
<P>Param A:<INPUT id="tbParamA" TYPE="text"></P>
<P>Param B:<INPUT ID="tbParamB" TYPE="text"></P>
<P>Param C:<INPUT ID="tbParamC" TYPE="text"></P>
<BUTTON onclick="Done()" type="button">OK</BUTTON>
</BODY>
</HTML> --------------------编程问答-------------------- 父页面
var obj = window.showModalDialog(URL,"传值",null);
子页面
接收:var obj = window.dialogArguments;
返回:window.returnValue = "返回"; --------------------编程问答-------------------- 哪位能够加我,我们QQ详聊行吗?
78049746 --------------------编程问答-------------------- 看我的blog,就这个csdn的,有说明,有例子。 --------------------编程问答-------------------- var MyArgs = window.showModalDialog("ChildWebForm.htm", MyArgs, WinSettings);
if (MyArgs == null)
{
window.alert("Nothing returned from child. No changes made to input boxes")
}
else
{
retvalA.value=MyArgs[0].toString();
retvalB.value=MyArgs[1].toString();
retvalC.value=MyArgs[2].toString();
}
function Done() {
var ParmA = tbParamA.value;
var ParmB = tbParamB.value;
var ParmC = tbParamC.value;
var MyArgs = new Array(ParmA, ParmB, ParmC);
window.returnValue = MyArgs;
window.close(); --------------------编程问答-------------------- 很火大~~~~
找了半天关于showModelessDialog()的使用方法,结果写的全是showModalDialog()的使用方法,你们平时都这么开发的吗?没看到多了一个是 Modal一个是Modeless吗?这两个一样吗?我去~ --------------------编程问答-------------------- 父页面:
JS:
result = window.showModalDialog("","","");
//result就是模式化弹出窗口返回的值
子页面:
JS:
window.returnValue='ok'; //这里随便写值 例<% %>,document.getElementById("id").text各种写法返回值
window.close(); --------------------编程问答-------------------- 打开对话框时可将对象传入然后复制;
要是OPEN
window.operner.document.getelementbyid("").value=xxxx
类似内容.
补充:.NET技术 , ASP.NET