?
Solved

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

Posted on 2011-03-08
7
Medium Priority
?
403 Views
Last Modified: 2012-06-27
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
Comment
Question by:ayha1999
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 29

Expert Comment

by:Paul Jackson
ID: 35070637
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
 
LVL 7

Author Comment

by:ayha1999
ID: 35070666
could u please give me a sample using "returnValue"?

thanks
0
 
LVL 2

Expert Comment

by:cookiej
ID: 35070756
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 29

Expert Comment

by:Paul Jackson
ID: 35070840
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
 
LVL 7

Author Comment

by:ayha1999
ID: 35070864
could you please post the complete script on how to use it on button click and hyperlink?

thanks
0
 
LVL 29

Accepted Solution

by:
Paul Jackson earned 1000 total points
ID: 35071217
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
 
LVL 7

Author Closing Comment

by:ayha1999
ID: 35083179
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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question