window.opener.document.getElem ... [英] window.opener.document.getElem...
问题描述
我想在aspx页面之间传递值.我创建了一个作为父级的aspx页面和另一个作为子级的aspx页面.现在,我使用 window.open()打开了子页面.孩子打开后,我使用 window.opener.document.getElementById().value 将一些值传递给父对象.这是代码段
父页面:
hi i want to pass value between aspx pages. I created one aspx page which acts as parent and another aspx page which acts as child. Now i opened the child page using window.open(). After the child is opened i passed some value to the parent using window.opener.document.getElementById().value .here is the code snippet
Parent page:
function open_child()
{
window.open("child.aspx");
}
子页面:
Child page:
function passvalue()
{
window.opener.document.getElementById("TextBox1").value="hello";//TextBox1 is in parent page
}
当我将值从普通子级(aspx表单页面)传递给父级(aspx表单页面)时,上述代码可以正常工作.但是问题是在将值从子(aspx表单页)传递给父级时,父级是母版页的内容页.我得到的错误是 window.opener为null或不是对象.这个错误有解决方案吗?欢迎使用其他方法!
The above code works fine when im passing value from normal child(aspx form page) to parent(aspx form page). But the problem is while passing value from child(aspx form page) to parent which is a content page of a masterpage. The error i get is window.opener is null or not an object . Any solution for this error? alternate methods are welcomed!
推荐答案
在确定"按钮事件中尝试此操作
try this in ok button event
//this is when u taken popup as normal (window.open) dialog it will return value to parent page
Session["id"] = CCode;
ScriptManager.RegisterStartupScript(Page, this.GetType(), "CCode", "<script>window.opener.document.forms[0].submit();window.close();</script>", false);
//this is when u taken popup as showmodal(window.showmodaldialog) dialog it will return value to parent page
Session["Code"] = Code;
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "A", "<script>window.returnValue = true;window.close();</script>");
也请阅读文章
Window.showmodaldialog [ ^ ]
Window.Open [ ^ ]
read article also
Window.showmodaldialog[^]
Window.Open[^]
这篇关于window.opener.document.getElem ...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!