tags:

views:

179

answers:

3

Hi, I am working in an ASP .net mvc project. The weird issue is I am running a javascript/jquery which randomly gives object required error. Sometimes it occurs but sometime it does not occur at all. What I am doing is making an explicit link click call to load a page as follows:

function LoadPopup()
{
    $("#page2link").click();
}

I call Loadpopup() in $(document).ready()

After the above gets executed, page2 loads and the javascript for page2 is trying to run but I dont know why suddenly page2's javascript throws error. I don't know exactly at what line it throws error. The break point comes at MicrosoftAjax.cs[Dynamicfile].

I am wondering why my debugger does not hit the breakpoint that I placed in page2's javascript. The stackj trace however shows a list of "java script anonymous functions" and also shows that these anonymous fucntions are called from loadpopup().

Some more information. I am having a master page. Loadpopup() runs when mystartup.aspx loads, which inherits from the master page. Can anyone please help me in this regard? Please let me know if you need more detail?

+1  A: 

Get Firefox and install the Firebug plugin. Load your page, activate Firebug for the page and then reload. You may receive instant enlightenment. If not, put a breakpoint a loadpopup() and step through the code.

Peter Rowell
A: 

Hi Peter, I am the same user who posted the question. May be my ID is different now. To my surprise I dont get the javascript object required error whne I used firefox and even the firebug did not higlight anything and everything went fine. But I dont know why I am getting the error in IE alone.

SARAVAN
Well, IE is definitely a different beast than FF. There is a FirebugLite plugin (http://getfirebug.com/lite.html) that you can load with your pages and it will give you some of the capabilites of FB in FF.
Peter Rowell
Well If I am not able to get the error in Firefox, then I am not sure if firebug helps in my case. The problem just comes with IE alone. Is there anything that I can do to debug in IE?
SARAVAN
A: 

Peter, I might be doing something wrong in the javascript like trying to access some form elemnts even before the page is rendered or the form elements are not available at somepoint. Let me put my question in someother way. Can we have a javascript to run once after the pageload is complete.

Say that my controller returns a view, renders it and then I want run some jquery/javascript to run. How can I run the javascript after the page loads completely?

SARAVAN