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

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
0
jonathan_hills
Asked:
jonathan_hills
  • 2
  • 2
1 Solution
 
BardobraveCommented:
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.

0
 
jonathan_hillsAuthor Commented:
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()
}
0
 
BardobraveCommented:
It hasn't to be executed before the server call. It has to be executed with the server call. You must check your server call execution line and ensure that the element is created and has the expected values when execution time arrives at this 598 line.

To do this you can use javascript debuggers like firebug, the error console of Web Developer Toolbar, etc... or simply by intercaling alerts at strategic points of the code and seeing what values return that alerts.
0
 
jonathan_hillsAuthor Commented:
Not enough info on howe t o solve issue
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

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