E-Mail:
Get our new Windows 7 eBook (PDF) for $7 with 70+ Tips. Download Now!

Programatically Clicking Button in an Accordion to Bypass AJAX Bug

Okay, so there’s this bug in the AJAX Accordion that prevents a nested button from firing on the first click. That is, you have to click the button twice to cause its event handler to fire.

The bug was apparently added to the AJAX team’s long list of bugs to fix a year ago around the time ASP.NET AJAX went RTM. I downloaded the newest build and even tried a custom build J modified for this purpose. Alas, no luck.

So there is apparently no build of AjaxControlToolkit.dll that supports Accordions with buttons you can click and get the event handler to fire the first time.

So I came up with a cheap, jury-rigged solution that Scotty himself would be proud of:

<body style=”width: 1000px;” onload=”document.forms[0]..click()”>

In this example, btnDoStuff is a button in the Accordion; but clicking any button in the accordion will enable the other buttons in the accordion to start firing appropriately. So by setting the onload property of the HTML BODY tag to click the button, the first partial-page postback fires immediately and enables the firing of the button event handlers.

I don’t know if this bug only happens when the Accordion is in an UpdatePanel, but mine was.

What Do You Think?

 
34 queries / 0.134 seconds.