• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 416
  • Last Modified:

Error: 'opener.document' is null or not an objectQuestion:

The above error occurs when I click a hyperlink on a child window. How can I solve the problem?

<input onclick="Javascript:window.showModalDialog('Customers.aspx', '', 'dialogWidth:300px;dialogHieight:300px;status=no;scrollbars=no;');"  return false" type="button" value="Pick" />

 <a href="#" onclick="opener.document.forms[0].txtCustId.Text='<%# Eval("Id") %>';opener.document.forms[0].txtName.Text='<%# Eval("Name") %>'; window.close(); return false"> <%# Eval("Id")%></a>

thanks

ayha
0
ayha1999
Asked:
ayha1999
  • 3
  • 3
1 Solution
 
Paul JacksonCommented:
window.opener does not work when used with showModalDialog I'm afraid, the only thing available is the returnValue that can be set on the child page.
You could pass back some comma seperated values back or something like that :

Otherwise you would have to go back to using window.open

0
 
ayha1999Author Commented:
could u please give me a sample using "returnValue"?

thanks
0
 
cookiejCommented:
showModalDialog is not a window the same way window.open is.  So, yeah, window.opener is null.

Check out this page:

http://msdn2.microsoft.com/en-us/library/ms536759.aspx

Use 'dialogArguments' to move do updates and such.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
Paul JacksonCommented:
Code for parent page
<script type="text/javascript"> 
function openModalWindow(url, height, width) { 
    var features = 'dialogWidth:' + width + ';dialogHeight:' + height + ';status:no;scrollbars:no;' 
    var rVal = window.showModalDialog(url, "", features); 
    if (rVal != null)
    {
        document.getElementById("mycontrolId1").Value = rVal[0];
        document.getElementById("mycontrolId2").Value = rVal[1];
    }
} 
</script> 

Open in new window


code for child page called from a save button or close button
<script type="text/javascript">
function closeWindow()
{
    var arrReturnVals = new Array(document.getElementById(ctrl1).Value, document.getElelmentById(ctrl2).Value);
    window.returnValue = arrReturnVals;
    window.close();
}
</script>

Open in new window

0
 
ayha1999Author Commented:
could you please post the complete script on how to use it on button click and hyperlink?

thanks
0
 
Paul JacksonCommented:
Parent Page :
<script type="text/javascript">   
function openModalWindow(url, height, width) {   
    var features = 'dialogWidth:' + width + ';dialogHeight:' + height + ';status:no;scrollbars:no;'   
    var rVal = window.showModalDialog(url, "", features);   
    if (rVal != null)  
    {  
        document.getElementById(<%=txtCustId.ClientId%>).Text = rVal[0];  
        document.getElementById(<%=txtName.ClientId%>).Text = rVal[1];  
    }  
}   
</script>

<input onclick="Javascript:window.openModalWindow('Customers.aspx', 300px,300px');"  return false" type="button" value="Pick" />

Open in new window


Child Page:
<script type="text/javascript">  
function closeWindow()  
{  
    var arrReturnVals = new Array(<%# Eval("Id")%>, <%# Eval("Name")%>);  
    window.returnValue = arrReturnVals;  
    window.close();  
}  
</script> 

<a href="#" onclick="closeWindow()"></a>

Open in new window

0
 
ayha1999Author Commented:
thanks
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now