开发者

ajax javascript error, break point points to the view state?

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)"开发者_如何学C.

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


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


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜