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
jonathan_hillsAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jonathan_hillsAuthor Commented:
Not enough info on howe t o solve issue
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.