当前位置: 代码迷 >> ASP.NET >> showModalDialog传参有关问题
  详细解决方案

showModalDialog传参有关问题

热度:593   发布时间:2013-02-25 00:00:00.0
showModalDialog传参问题
想获取father.aspx的TextBox1的内容,显示在child.aspx的TextBox_PN中
利用showModalDialog打开的模态窗口,返回值暂时不考虑,可能不需要

C# code
father.aspx<script language="javascript" type="text/javascript">function openChild(){   window.showModalDialog("child.aspx",window,"dialogWidth=450px;status=no;help=no");}</script>


C# code
child.aspx<base target="_self" /><script language="javascript" type="text/javascript">var k=window.dialogArgumetns;  if(k!=null){    document.getElementById("TextBox_PN").value=k.document.getElementById("TextBox1").value;}</script>


为什么结果显示不出来,是不是代码有问题

还望大神们指点迷津,其他的传参方法也行,只要能达到目的就行

------解决方案--------------------------------------------------------
<script language="javascript" type="text/javascript">
var k=window.dialogArgumetns;
if(k!=null)
{
document.getElementById("TextBox_PN").value=k.document.getElementById("TextBox1").value;
}
</script>

改成
<script language="javascript" type="text/javascript">

var k=window.dialogArgumetns;
window.onload=function()
{
if(k!=null)
{
document.getElementById("TextBox_PN").value=k.document.getElementById("TextBox1").value;
}
}
</script>
------解决方案--------------------------------------------------------
另外,确保你 的 Textbox没有控件的嵌套,保证id是没有改变
  相关解决方案