Problem Adding a Dynamic Control

3 posts, 1 answers
  1. Richard Nash
    Richard Nash avatar
    6 posts
    Member since:
    Dec 2009

    Posted 18 Dec 2009 Link to this post

    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. Answer
    Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 21 Dec 2009 Link to this post

    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.
  3. Richard Nash
    Richard Nash avatar
    6 posts
    Member since:
    Dec 2009

    Posted 21 Dec 2009 Link to this post

    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.
Back to Top