Solved

Microsoft JScript runtime error: 'window.opener.location' is null or not an object

Posted on 2011-03-11
6
1,577 Views
Last Modified: 2012-05-11
I get this error when trying to close my popup.

This worked fine in chrome
0
Comment
Question by:vbnetcoder
6 Comments
 

Author Comment

by:vbnetcoder
ID: 35110958
This is my ASP.net code that works fine in chrome
Imports System.Data
Imports System.IO

Partial Class CategoryEditPopup
    Inherits System.Web.UI.Page
    Dim clsProduct As New clsProduct
    Dim CategoryID As String
    Dim MainCategoryName As String
    Dim ImageCount As Integer

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        btnCancel.OnClientClick = "javascript:window.opener.location.reload();self.close();"
        btnRemove.OnClientClick = "javascript:window.opener.location.reload();self.close();"

        CategoryID = Request.QueryString("Category_ID")


        MainCategoryName = GetCategoryName(CategoryID)

        ImageCount = clsProduct.ReturnImageCountByCategoryID(CategoryID)

        If Not IsPostBack Then
            LoadCategoriesList()
            LoadFormInfo()

        End If

    End Sub
    Private Sub LoadFormInfo()

        Dim dr As SqlClient.SqlDataReader = clsProduct.ReturnSpecificCategoryDetailsSubMainDataReader(CategoryID)

        dr.Read()
        lblCategoryID.Text = dr("Category_ID")
        txtName.Text = dr("Category_Name")
        txtDescription.Text = dr("Category_Description")


        dr.Close()

        GetCategoryPath()

    End Sub
    Private Sub GetCategoryPath()

        lblCategoryPath.Text = "/" & clsProduct.ReturnCategoryPath(CategoryID)

    End Sub
    Private Sub LoadCategoriesList()

        Dim dr As SqlClient.SqlDataReader
        dr = clsProduct.ReturnCategoriesList(dr)
        ddCategories.Items.Clear()
        ddCategories.Items.Add("None")

        Do While dr.Read
            ddCategories.Items.Add(dr("Category_Name"))
        Loop

        dr.Close()

        MainCategoryName = GetCategoryName(CategoryID)

        If Not MainCategoryName = "" Then
            ddCategories.SelectedItem.Text = MainCategoryName
        End If


        ddCategories.Dispose()

    End Sub
    Private Function GetCategoryName(ByVal CategoryID As String) As String

        MainCategoryName = clsProduct.ReturnCategoryNameByCategoryID(CategoryID)
        Return MainCategoryName

    End Function
    Protected Sub btnSave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSave.Click

        If Not (Trim(txtName.Text) = "") Then
            Dim imgStream As Stream = FileUpload1.PostedFile.InputStream
            Dim imgLen As Integer = FileUpload1.PostedFile.ContentLength
            Dim imgContentType As String = FileUpload1.PostedFile.ContentType
            Dim imgName As String = FileUpload1.FileName
            Dim imgBinaryData As Byte() = New Byte(imgLen - 1) {}

            Dim n As Integer = imgStream.Read(imgBinaryData, 0, imgLen)

            clsProduct.UpdateCategory(CategoryID, txtName.Text, txtDescription.Text, ddCategories.Text, _
                                       imgBinaryData, imgName, imgContentType)
            'LoadCategoriesList()
            LoadFormInfo()

        End If

    End Sub

    Protected Sub btnRemove_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnRemove.Click
        clsProduct.DeleteCategoryByCategoryID(CategoryID)
    End Sub
    
    Protected Sub btnCancel_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCancel.Click

    End Sub

Open in new window

0
 
LVL 23

Expert Comment

by:Rajkumar Gs
ID: 35114680
Javascript code using to close ?

Raj
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 35114691
"javascript:window.opener.location.reload();self.close();" doesn't make any sense to me.  

window.open() opens a new window, window.location.reload() reloads the current window.  I don't understand what the two do together.
0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 35114774
@Dave: It is perfectly correct code
window.opener.location.reload() will reload the window that spawned the popup
self.close() will close the popup

We also need to see the code that opened the window and if the code you posted might live in an iframe
0
 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 500 total points
ID: 35114789
Never seen "window.opener.location.reload()" before.  Here's a page that claims one solution: http://social.msdn.microsoft.com/Forums/en/iewebdevelopment/thread/0c014e78-8d35-4df3-93da-7f6a30b4ed8b

0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 35114800
That seems to be a vista+ option

Let's first see if it is not due to other things like
<a href="someurl" onclick="window.open(....)">click</a>
without a return false, which may unload the opener invisibly
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Initial get page response times and IIS8 15 49
updating order of the rows, N+1 query issue, C#, asp.net, MVC, SQL Server 3 25
ASP.NET MVC identity 6 26
Jquery keyup 4 17
Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
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…

786 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