在两个页面之间互相写其控件内的值
定义A页面,定义TextBox id="TextBox1"和Button id="Button1"
后台代码:
private
void
Page_Load(
object
sender, System.EventArgs e)
{
this
.Button1.Attributes.Add(
"
onclick
"
,
"
window.open('SelectData.aspx?rec=TextBox1','newwin','toolbar=no,menubar=no,status=no,location=no,resizable=no,scrollbars=no,width=218,height=185,top=190,left=300');return false;
"
);
}
定义界面B: TextBox id="TextBox1"和Button id="Button1" 和type="hidden" id="name"
脚本:
<
SCRIPT language
=
"
JavaScript
"
>
var
parwindow;
parwindow
=
self.opener;
var
recv
=
document.all(
"
name
"
).value;
if
(parwindow
!=
null
)
{
document.all(
"
TextBox1
"
).value
=
parwindow.document.all(recv).value;
}
function
changetext()
{
if
(parwindow
!=
null
)
{
try
{
parwindow.document.all(recv).value
=
document.all(
"
TextBox1
"
).value;
}
catch
(e)
{
}
}
}
</
SCRIPT
>
放在form后
后台代码:
private
void
Page_Load(
object
sender, System.EventArgs e)
{
name.Value
=
Request.QueryString[
0
];
this
.Button1.Attributes.Add(
"
onclick
"
,
"
changetext();window.close()
"
);
}

浙公网安备 33010602011771号