views:

26

answers:

3

I have an aspx page that is getting an Object Expected javascript error on submit, but when you break into the error the breakpoint is somewhere in the middle of the __VIEWSTATE input html element.

A javascript stack dump shows just "{anonymous}(null)".

What does this mean and how does one go about debugging further?

+1  A: 

This usually means that during the loading of your page, you are calling a javascript method which is not present or loaded in that page. First you need to ensure all the methods called during loading of your page is available and then you can check if those calls are made before methods are getting loaded.

Not sure if this helps, but try debugging using the firebug in firefox. You might even hit on the javascript method which is being called

Sachin Shanbhag
This wasn't the problem but eventually led to it, thank you.
asawyer
A: 

Try to use chrome for debugging js, i used to see such errors when debugging in ie8

vittore
A: 

Finally found the culprit. Somone checked in a change to the submit button on the form, it went from:

<asp:Button ID="btnSubmit" runat="server" Text="Submit" 
onclick="btnSubmit_Click" />

To:

 <asp:Button ID="btnSubmit" runat="server" Text="Submit" 
 **onClientClick="doSomeUnrelatedCleanup();return true;"**
 onclick="btnSubmit_Click" />

Then when asp.net parses the page it adds

WebForm_DoPostBackWithOptions(....)

To the end of the onClientClick attribute, except now because of the return true, it never executed the Web Forms post back call.

asawyer