This is a migrated thread and some comments may be shown as answers.

Problem Adding a Dynamic Control

2 Answers 232 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Richard Nash
Top achievements
Rank 2
Richard Nash asked on 19 Dec 2009, 02:52 AM
This problem is difficult to describe, so bear with me.

I have a user control that I built, that contains a RadAjaxPanel along with a RadAjaxLoadingPanel and some other controls.  I then have an aspx page that contains another RadAjaxPanel and RadAjaxLoadingPanel.  I have wrote some server side code that will add the user control to a panel on the page dynamically when a button within the aspx page's RadAjaxPanel is clicked.  The panel that the control gets added to has been delegated as an UpdateControl in the RadAjaxManager, so as to avoid a complete postback.  I have made sure to write the server side code, so that the user control's ID and all of its containing ctrl's ID's are unique with an incremented number on the end.  This however is not preventing a javascript runtime errors from popping up when I test this in debug.  The errors are as follows:  

"Sys.InvalidOperationException: A control is already associated with the element."
"Sys.InvalidOperationException: Two components with the same id 'dynamicRADAJAXPanelID' can't be added to the application."

I have checked all the control ID's and none are the same.  The web page function properly, and does add the controls dynamically, but still throws the exception.  If I ignore the exceptions, the page renders and functions properly.

If anyone knows of any issues with adding RadControls dynamically, or with adding controls dynamically in an AJAX postback rather than a full postback, please help me out.  If you need to see the code, let me know. 

Thanks.

2 Answers, 1 is accepted

Sort by
0
Accepted
Iana Tsolova
Telerik team
answered on 21 Dec 2009, 12:23 PM
Hi Richard,

I suggest that you replace the RadAjaxPanels with ASP:Panel controls and use only RadAjaxManager for page ajaxifying but both RadAjaxManager and RadAjaxPanel as described here. In the user control, you can handle the Page_PreRender event and add the ajax settings there dynamically.

Give it a try and let me know if any issues arise.

Sincerely yours,
Iana
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Richard Nash
Top achievements
Rank 2
answered on 21 Dec 2009, 02:01 PM
That worked!  I took out the RadAjaxPanels and just used the manager and it works like a champ!!  Thank you so much for your quick response!  I would have spent hours on this.
Tags
Ajax
Asked by
Richard Nash
Top achievements
Rank 2
Answers by
Iana Tsolova
Telerik team
Richard Nash
Top achievements
Rank 2
Share this question
or