I have been trying to write a custom composite control that can be dynamically loaded. My control contains an UpdatePanel which, in turn, contains 4 ImageButtons and a TextBox control.
I want to allow the user to create as many instances of my control as they like. I create the control in response to a Button Click event and then I add each newly created custom control to a Panel control and to the Session. In the Page_Init method I handle the postback by getting each custom control from the Session and then re-adding the control to the Panel control. This is the point where I get the exception that you are describing.
I tried calling ScriptManager.RegisterAsyncPostBackControl() passing in the UpdatePanel contained by my custom control, but I get the same exception.
I have tried two approaches to writing the custom control; I first wrote my own control that was derived from CompositeControl and aggregated an UpdatePanel directly.
Next I looked at Nikhil Kothari's sample and used his CompositionUpdatePanel class. I got the same exception with both approaches.
Here is the link to Nikhil's sample:
http://www.nikhilk.net/AtlasM2.2.aspx
NOTE: I had to make a few minor changes to Nikhil's sample to get it to compile using the latest AJAX libraries.
I am going to keep working on this - any ideas on how to get over this hurdle would be greatly appreciated.
Thanks