Link to home
Start Free TrialLog in
Avatar of jonathan_hills
jonathan_hillsFlag for Canada

asked on

C# dialogwin.win is null or not an object

Hi

When i try and call a java script from C# like this,

  this.webBrowser1.Document.Window.Frames["RightPane"].Document.InvokeScript("addFilePopUp", new object[] {"20092","20057"} );. I get an dialogwin.win is null or not an object. See attached file. I have also included the html file. Any Ideas???

Cheers
     
a.jpg
Developer-Tools---http---usmovsa.htm
Avatar of Bardobrave
Bardobrave
Flag of Spain image

The error you are receiving states that somewhere on your javascript code you are trying to access to an attribute of an object that's not loaded on the moment is being accessed.

You should check that 598 line on your FormasLib.js file and seek where dialogWin object is loaded, maybe the code where that object is defined is not being executed when you make the call from server code.

Avatar of jonathan_hills

ASKER

Hi

Attached is the function that causes the error. I marked line 598. How do I make sure the code is executed before I make a call to the server code?
 
// Generate a modal dialog.
// Parameters:
//    url -- URL of the page/frameset to be loaded into dialog
//    width -- pixel width of the dialog window
//    height -- pixel height of the dialog window
//    target -- window name where to load
//    scrollbars -- include scrollbars in window?
//    isResizable -- is window resizable?
function openModalDialog(url, width, height, target, scrollbars, isResizable, isExternal, status)
{
        dialogWin = new Object()

        // Initialize properties of the modal dialog object.
        dialogWin.returnedValue = ""
        dialogWin.url = url
        dialogWin.width = width
        dialogWin.height = height

        var external = false ;
        if ( typeof(isExternal) != "undefined" && isExternal != null )
            external = isExternal;

        if ( scrollbars == null || !scrollbars )
            dialogWin.scrollbars = 0
        else if ( scrollbars == "true" )
            dialogWin.scrollbars = "yes"
        else
            dialogWin.scrollbars = scrollbars

        if ( isResizable == null || isResizable )
            dialogWin.resizable = "yes"
        else if (!isResizable || isResizable == "false")
            dialogWin.resizable = "no"
        else
            dialogWin.resizable = isResizable

        if ( status == null || !status )
            dialogWin.status = "no";
        else if ( status == "true" )
            dialogWin.status = "yes";
        else
            dialogWin.status = status;

        // Keep name unique so Navigator doesn't overwrite an existing dialog.
        dialogWin.name = target

        if ( target == "" || !target )
            dialogWin.name = (new Date()).getSeconds().toString()

        // Assemble window attributes and try to center the dialog.
        if (Nav) {
            // center in screen.
            dialogWin.left = window.screenX + ((window.outerWidth - dialogWin.width) / 2)
            dialogWin.top = window.screenY + ((window.outerHeight - dialogWin.height) / 2)

            var attr = "screenX=" + dialogWin.left + ",screenY=" + dialogWin.top

            attr += ",width=" + dialogWin.width + ",height=" + dialogWin.height + ",resizable=" + dialogWin.resizable + ",scrollbars=" + dialogWin.scrollbars + ",status=" + dialogWin.status
        } else {
            // center in screen.
            dialogWin.left = (screen.width - dialogWin.width) / 2
            dialogWin.top = (screen.height - dialogWin.height) / 2

            var attr = "left=" + dialogWin.left + ",top=" + dialogWin.top

            attr += ",width=" + dialogWin.width + ",height=" + dialogWin.height + ",resizable=" + dialogWin.resizable + ",scrollbars=" + dialogWin.scrollbars + ",status=" + dialogWin.status
        }

        if (dialogWin.url == null || dialogWin.url== ""){
                  var frm = getForm('');
                  var objurl = "";
                  if(frm) {
                        if(frm.objid && frm.classid && frm.tabid) {
                              objurl = "?objid="+frm.objid.value+"&classid="+frm.classid.value+"&tabid="+frm.tabid.value;
                        }
                  }
                  if(objurl.length > 0) {
                        dialogWin.url = "PopupLoading.jsp"+objurl;
                  } else {
                        dialogWin.url = "PopupLoading.jsp";
                  }            
        }

        // Generate the dialog and make sure it has focus.
        dialogWin.win = window.open(dialogWin.url, dialogWin.name, attr)

        // need these for Solaris
        if (typeof is_sun == "undefined") is_sun = (navigator.userAgent.toLowerCase().indexOf("sunos")!=-1);
        if ( is_sun && dialogWin.win && !external)
        {
            dialogWin.win.resizeTo(dialogWin.width,dialogWin.height);
            dialogWin.win.moveTo(dialogWin.left,dialogWin.top);
        }

  Line 598      dialogWin.win.focus()
}
ASKER CERTIFIED SOLUTION
Avatar of Bardobrave
Bardobrave
Flag of Spain image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Not enough info on howe t o solve issue