我在A页面有TXT1,TXT2两个文本框,还有个按钮,现在点该按钮用window.showModalDialog("b.aspx",window,"dialogHeight:400px;dialogWidth:600px;center:Yes;Help:No;Resizable:No;Status:Yes;Scroll:auto;Status:no;");打开B页面.
在B页面用查询按钮查询一些记录.还有个确定按钮.比如用DATADRID查出一条记录,有两列,现在要点确定按钮把第一列数据返回给
TXT1,把第2列返回给TXT2,怎么实现呀,希望大家给个解释谢谢
在B页面用查询按钮查询一些记录.还有个确定按钮.比如用DATADRID查出一条记录,有两列,现在要点确定按钮把第一列数据返回给
TXT1,把第2列返回给TXT2,怎么实现呀,希望大家给个解释谢谢
StringBuilder sb=new StringBuilder ();
sb.Append ("<script>var parwin = window.dialogArguments;");
sb.Append (",");
sb.Remove (sb.Length-1,1);
sb.Append ("parwin.document.getElementById(\"txt1\").value=");sb.Append (this.dg1.SelectedItem.Cells[0].Text);
sb.Append (";");
sb.Append ("parwin.document.getElementById(\"txt2\").value=");
sb.Append (this.dg1.SelectedItem.Cells[1].Text);
sb.Append (";");
sb.Append ("'</script>");
Response.Write(sb.ToString ());
var ret = window.showModalDialog("...");if (ret != null)
{
window.document.getElementById("txt1").value = ret[0];
window.document.getElementById("txt2").value = ret[1];
}B页面html javascript代码:
function windowclose(str1, str2)
{
var ret = new Array(2);
ret[0] = str1;
ret[1] = str2;
window.returnValue = ret;
}
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>无标题页 </title>
<script type="text/javascript">
function btnClick()
{
var ret = window.showModalDialog("b.aspx"); if (ret != null)
{
window.document.getElementById("TextBox1").value = ret[0];
window.document.getElementById("TextBox2").value = ret[1];
}
return false;
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="return btnClick();" />
</div>
</form>
</body>
</html> b.aspx
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>无标题页</title>
<script type="text/javascript">
function btnClick()
{
var ret = new Array(2);
ret[0] = "aa";
ret[1] = "bb";
window.returnValue = ret;
window.close();
return false;
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="return btnClick()" /> </div>
</form>
</body>
</html>
<head>
<style>
input.focus{border:solid 2px blue;}
</style>
<script type="text/javascript">
var arg=dialogArguments;//获取使用showModalDialog传递的参数
function SetValue()
{
arg.document.getElementById("txt1").value="text1";
arg.document.getElementById("txt2").value="text2";
self.close()
}
</script>
</head>
<body>
<input type="button" onclick="SetValue()" value="SetValue"/>
</body>
</html>