Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).Telerik.Web.UI.RadAjaxControl.MoveUpdatePanel

The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[HttpException (0x80004005): The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).]
   System.Web.UI.ControlCollection.AddAt(Int32 index, Control child) +8668018
   Telerik.Web.UI.RadAjaxControl.MoveUpdatePanel(Control initiator, Control updated) +133

[HttpException (0x80004005): Please, see whether wrapping the code block, generating the exception, within RadCodeBlock resolves the error.]
   Telerik.Web.UI.RadAjaxControl.MoveUpdatePanel(Control initiator, Control updated) +181
   Telerik.Web.UI.RadAjaxControl.PerformRender() +375
   Telerik.Web.UI.RadAjaxControl.OnPageRender(HtmlTextWriter writer, Control page) +1222
   Telerik.Web.UI.RadAjaxControl.RenderPageInAjaxMode(HtmlTextWriter writer, Control page) +95
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +256
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19
   System.Web.UI.Page.Render(HtmlTextWriter writer) +29
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1266
like image 903
user3493106 Avatar asked Oct 21 '25 04:10

user3493106


2 Answers

You can also have this problem without using telerik so much better solution is to add an

palceholder instead of RadCodeBlock which will fit for all cases

    <asp:PlaceHolder ID="PlaceHolder1"
your script 

 runat="server"></asp:PlaceHolder>
like image 132
Konark Avatar answered Oct 22 '25 16:10

Konark


This usually happens if you used "<%= %> or <%# %>" in your page you need to use RadcodeBlock.

Example :

<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
      //your script
   </telerik:RadCodeBlock>
like image 44
Zaki Avatar answered Oct 22 '25 17:10

Zaki



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!