ASP.NET AJAX Update Panels swallow detail – What’s the real error?

Here’s one that caught me out last night (and I’m ashamed to say I spent several hours on this).

Simple scenario, a DataList bound to LINQ2SQL Data Source. Each row has an edit button and the panel that allows detail editing was being displayed via a Modal Popup Extender. And the whole thing is inside an Update Panel (with EnablePartialRendering = true).

Initially, I was just displaying the panel to allow editing and everything worked fine. Then I wrote the code that responded to the "Edit" command from the DataList (basically populating the panel’s controls with data for that record). Then a test run and …

[Exception... "'Sys.WebForms.PageRequestManagerServerErrorException: Sys.WebForms.PageRequestManagerServerErrorException:
Cannot have multiple items selected in a DropDownList.' when calling method:
[nsIDOMEventListener::handleEvent]"  nsresult: "0x8057001c (NS_ERROR_XPC_JS_THREW_JS_OBJECT)"
location: "JS frame :: chrome://firebug/content/spy.js :: onHTTPSpyReadyStateChange :: line 497"  data: no]
http://localhost:1606/ScriptResource.axd? ……… etc

Now on reflection the error was clear (and yes I was doing something funky with a DropDownList), however Firebug was displaying the error as originating in a method to do with Date Abbreviations. This threw me and I started looking for data format errors and the like. Finally, I switched of EnablePartialRendering and lo and behold a stack trace.

Forget was actually happening, the lesson learned is, develop with EnablePartialRendering set to false or at very least remember to do that when you get one of these odd errors that is being eaten by AJAX/the UpdatePanel etc.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s