a blog for those who code

Monday 31 December 2018

How I solved Sys.InvalidOperationException: A control is already associated with the element

In this post I will show you how I fixed Sys.InvalidOperationException: A control is already associated with the element error when I was using RedTreeView of Telerik. I was working with Telerik RadTreeView and was using RadAjaxPanel to automatically refresh the treeview on click of a button. This was giving me the above error "Sys.InvalidOperationException: A control is already associated with the element".

To fix this issue I have changed

<asp:ScriptManager ID="ScriptManager1" runat="server" 

<telerik:RadScriptManager ID="ScriptManager1"  runat="server"> 

in Master Page.

After changing ScriptManager to RadScriptManager I was getting another error "'~/Telerik.Web.UI.WebResource.axd' is missing in web.config. RadScriptManager requires a HttpHandler registration in web.config. Please, use the control Smart Tag to add the handler automatically, or see the help for more information: Controls > RadScriptManager". To fix this error I have added below code

  <add path="Telerik.Web.UI.DialogHandler.aspx" 
         type="Telerik.Web.UI.DialogHandler" verb="*" validate="false"/>
  <add path="Telerik.Web.UI.SpellCheckHandler.axd" 
         type="Telerik.Web.UI.SpellCheckHandler" verb="*" validate="false"/>
  <add path="Telerik.Web.UI.WebResource.axd" 
         type="Telerik.Web.UI.WebResource" verb="*" validate="false"/>

  <add name="Telerik_Web_UI_DialogHandler_aspx" verb="*" 
       preCondition="integratedMode" path="Telerik.Web.UI.DialogHandler.aspx" 
  <add name="Telerik_Web_UI_SpellCheckHandler_axd" verb="*" 
       preCondition="integratedMode" path="Telerik.Web.UI.SpellCheckHandler.axd" 
  <add name="Telerik_Web_UI_WebResource_axd" verb="*" 
       preCondition="integratedMode" path="Telerik.Web.UI.WebResource.axd" 

This has fixed the issue and I was not getting any issues and the TreeView was updating as expected.

Please like and share the CodingDefined.com blog if you find it useful and helpful.

No comments:

Post a Comment