<telerik:RadAjaxManagerProxy ID="RadAjaxManagerProxy1" runat="server"> |
<AjaxSettings> |
<telerik:AjaxSetting AjaxControlID="JawbCategoryComboBox"> |
<UpdatedControls> |
<telerik:AjaxUpdatedControl ControlID="JawbOccupationComboBox" /> |
</UpdatedControls> |
</telerik:AjaxSetting> |
</AjaxSettings> |
</telerik:RadAjaxManagerProxy> |
It is the <telerik:AjaxUpdatedControl> line that is causing the issue. If I comment it out, the error goes away. I read the other posts about code within the <head> tags, but the only code in the <head> section is stylesheet code. There aren't any <% %> tags anywhere in the <head> section of the master page or any of the children. Here is the exact error:
[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) +8669270
Telerik.Web.UI.RadAjaxControl.MoveUpdatePanel(Control initiator, Control updated) +132
[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) +180
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
What else causes this error?
Thanks,
Bill
25 Answers, 1 is accepted
Could you please try to wrap your JavaScript code (no matter whether it is in the head section or not) in RadCodeBlock as depicted in the following article?
RadCodeBlock and RadScriptBlock
Best regards,
Daniel
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
There isn't any JavaScript code in the entire site that is not managed by the script processors, so it would be impossible to wrap it in those blocks as none of the code exists in the .aspx or .ascx files. Everything is managed.
Thanks,
Bill
The really bad thing about it is that there is absolutely no useful information in the error message to let you know what to look for. I spent the last 3 days trying to find a single control that was causing the the issue. This needs to be fixed.
Thank you for the explanation.
Could you please post a simple code-snippet that demonstrates the issue? We would like to investigate the behavior you depicted.
Best regards,
Daniel
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Not sure if this issue was sorted out, but I'm having the same behavior.
The portion of the RadAjaxManager that causes the problem is here:
<telerik:AjaxSetting AjaxControlID="QuickAddButton"> |
<UpdatedControls> |
<telerik:AjaxUpdatedControl ControlID="FarmsRadGrid" LoadingPanelID="FarmGridLoading" /> |
<telerik:AjaxUpdatedControl ControlID="FarmsObjectDataSource" /> |
<telerik:AjaxUpdatedControl ControlID="PageLoadErrorPopup" /> |
<telerik:AjaxUpdatedControl ControlID="FarmNameRadTextBox" /> |
</UpdatedControls> |
</telerik:AjaxSetting> |
The last AjaxUpdatedControl is a simple RadTextBox, but when I added it I got the same error as mentioned by Bill. Looking at his posts I went and added a <span runat="server"> around the RadTextBox in question and this solved the problem.
<span runat="server"> |
<telerik:RadTextBox ID="FarmNameRadTextBox" runat="server" SelectionOnFocus="SelectAll" |
Width="181px" EmptyMessage="[farm name...]" InvalidStyleDuration="100" LabelCssClass="radLabelCss_Vista"> |
</telerik:RadTextBox> |
</span> |
Why would this be happening? Before adding the server span element it wouldn't work, if I remove it the error comes back. It's just this control that causes the problem. I have quite a few other controls referenced in the AjaxManager and none of them caused this problem.
Regards,
Jacques
It is an issue with RadAjaxManager, and it still exists. I looked into the problem further, and the problem is with the way that they are wrapping the control dynamically with an UpdatePanel. If the ControlID attribute of an AjaxUpdatedControl element references anything other than an UpdatePanel, that control is dynamically wrapped with an UpdatePanel, which is what is causing the problem. Simply wrapping the <% ... %> code within any server control allows you to work around the problem, which is what you observed. I'm hoping that it will be fixed soon, as the error messages often point you to the wrong section of code.
Take it easy,
Bill
Is there still no real fix for this?
I have a drag-and-drop example working fine on a test-page that uses my master page, but as soon as I try to use the code (and the RadAjaxManager) on a "real" page in my site, it blows up with the cited error. I've tried the workarounds noted in this forum, to no avail. I'm suspecting my ASP.NET Localization, where I have tags like LoadingText="<%$ Resources:resources, LoadingFromSvrLbl %>" ALL OVER THE PLACE. I cannot possibly put all of the localization code inside RadCodeBlocks. The error messages do not point to anything intelligible. It is like looking for a needle in an hay stack. A real pain... and a disappointment.
Any tips?
Thanks!
R
At this time, there is no other option. It took me about 4 hours to wrap every single <% Resources... %> tag in one site, so I know what you are going through. Unfortunately, you will need to do it if you want to use the controls.
Take it easy,
Bill
This:
http://www.aspnetresources.com/blog/code_blocks_inside_master_pages_cause_trouble
and a few judiciously applied RadCodeBlocks in my MasterPage did the trick. Not the prettiest thing in the world, but what the heck.
Best regards,
Richard
I had the same error message, but with a different cause. Mine was caused because I accidently removed the <form runat="server" id="form1"> tag.
The compiler had no trouble with the missing tag, but when running it gave the error mentioned in the startingpost.
Can you please post/attach some code so we can examine your approach?
In the meantime I recommend you examine the following blog post by Rick Strahl:
The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).
Regards,
Daniel
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
I have a master/content page, same error... here is the code of my content page:
Does the SqlDataSource cause the problem??
<asp:Content ID="Content1" ContentPlaceHolderID="CPH1" Runat="Server"> |
<script type="text/javascript"> |
function GetRadWindow() { |
var oWindow = null; |
if (window.radWindow) oWindow = window.radWindow; //Will work in Moz in all cases, including clasic dialog |
else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow; //IE (and Moz as well) |
return oWindow; |
} |
function Close() { |
GetRadWindow().close(); |
} |
//Se llama a la función que recarga el grid y se cierra la ventana secundaria |
function CloseAndRebind() { |
GetRadWindow().BrowserWindow.refreshGrid(); |
GetRadWindow().close(); |
} |
</script> |
<asp:SqlDataSource ID="DataSourceSistema" runat="server" ConnectionString="<%$ ConnectionStrings:SqlConnectionString %>" |
SelectCommand="SELECT * FROM [sistema_computacional] ORDER BY [nombre]" OldValuesParameterFormatString="original_{0}"> |
</asp:SqlDataSource> |
<telerik:RadAjaxManagerProxy ID="RadAjaxManagerProxy1" runat="server"> |
<AjaxSettings> |
<telerik:AjaxSetting AjaxControlID="Panel1"> |
<UpdatedControls> |
<telerik:AjaxUpdatedControl ControlID="Panel1" |
LoadingPanelID="RadAjaxLoadingPanel1" /> |
</UpdatedControls> |
</telerik:AjaxSetting> |
</AjaxSettings> |
</telerik:RadAjaxManagerProxy> |
<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" Runat="server" |
Skin="Default"> |
</telerik:RadAjaxLoadingPanel> |
<asp:Panel ID="Panel1" runat="server"> |
<table style="width: 100%" cellpadding="0" cellspacing="0"> |
<tr> |
<td style="text-align: left; width: 147px;" class="etiqueta"> |
Nombre:</td> |
<td> |
<telerik:RadTextBox ID="txtBoxNombre" Runat="server" |
EmptyMessage="No hay un nombre asignado al componente" Width="425px"> |
</telerik:RadTextBox> |
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" |
ControlToValidate="txtBoxNombre" ErrorMessage="Campo requerido"></asp:RequiredFieldValidator> |
</td> |
</tr> |
<tr> |
<td style="text-align: left; width: 147px;" class="etiqueta"> |
Descripción:</td> |
<td> |
<telerik:RadTextBox ID="txBoxDescripcion" Runat="server" |
EmptyMessage="Indique una descripción para el componente" Rows="5" |
TextMode="MultiLine" Width="425px"> |
</telerik:RadTextBox> |
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" |
ControlToValidate="txBoxDescripcion" ErrorMessage="Campo requerido"></asp:RequiredFieldValidator> |
</td> |
</tr> |
<tr> |
<td style="text-align: left; width: 147px;" class="etiqueta"> |
Sistema:</td> |
<td> |
<telerik:RadComboBox ID="rboxSistema" Runat="server" |
DataSourceID="DataSourceSistema" DataTextField="nombre" |
DataValueField="clave_sistema" Filter="Contains" AutoPostBack="True" |
ValidationGroup="none" Width="300px"> |
</telerik:RadComboBox> |
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" |
ControlToValidate="rboxSistema" ErrorMessage="Campo requerido"></asp:RequiredFieldValidator> |
</td> |
</tr> |
<tr> |
<td style="text-align: left; width: 147px;" class="etiqueta"> |
Tipo de Componente:</td> |
<td> |
<telerik:RadComboBox ID="rboxTipoComponente" Runat="server" |
EmptyMessage="No existen tipos de componentes para este sistema" |
Filter="Contains" ValidationGroup="none" Width="350px"> |
</telerik:RadComboBox> |
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" |
ControlToValidate="rboxTipoComponente" ErrorMessage="Campo requerido"></asp:RequiredFieldValidator> |
</td> |
</tr> |
<tr> |
<td style="text-align: left; width: 147px;" class="etiqueta"> |
Componente Activo:</td> |
<td> |
<asp:CheckBox ID="ckbActivo" runat="server" /> |
</td> |
</tr> |
<tr> |
<td style="text-align: left; font-weight: 700; " colspan="2"> |
<table style="width: 100%" cellpadding="1" cellspacing="0"> |
<tr> |
<td style="text-align: left; width: 147px;" class="etiqueta"> |
Archivos Asociados:</td> |
<td> |
<telerik:RadTextBox ID="txtBoxNewArchivo" Runat="server" Width="225px" |
ValidationGroup="archivos"> |
</telerik:RadTextBox> |
<asp:Button ID="btnAgregar" runat="server" Text="Agregar" CssClass="BotonAzul" |
ValidationGroup="archivos" /> |
<asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" |
ControlToValidate="txtBoxNewArchivo" ErrorMessage="Se requiere un nombre" |
ValidationGroup="archivos"></asp:RequiredFieldValidator> |
</td> |
</tr> |
<tr> |
<td colspan="2" style="text-align: left"> |
<table cellpadding="0" cellspacing="0" style="width: 100%"> |
<tr> |
<td style="text-align: left; width: 147px;"> |
</td> |
<td style="font-size: small; text-align: center" width="3%"> |
<b>Activo</b></td> |
<td> |
</td> |
</tr> |
<tr> |
<td> |
</td> |
<td colspan="2"> |
<telerik:RadListBox ID="radListArchivos" runat="server" AllowDelete="True" |
CheckBoxes="True" style="text-align: left" Height="125px" Width="400px"> |
<ButtonSettings TransferButtons="All" AreaWidth="90px" RenderButtonText="True" VerticalAlign="Middle"></ButtonSettings> |
</telerik:RadListBox> |
</td> |
</tr> |
</table> |
</td> |
</tr> |
</table> |
</td> |
</tr> |
<tr> |
<td style="text-align: right; font-weight: 700; width: 147px; height: 30px;"> |
</td> |
<td style="text-align: right; height: 30px;"> |
<asp:Label ID="lblError" runat="server" style="color: #CC0000" ></asp:Label> |
<asp:Button ID="btnGuardar" runat="server" Text="Guardar" |
CssClass="BotonAzul" /> |
<input id="Button1" class="BotonAzul" type="button" value="Cancelar" onclick="javascript: Close(); return false;" /></td> |
</tr> |
</table> |
</asp:Panel> |
<% =strJavascript%> |
</asp:Content> |
Is this issue resolved in new version. I am using 2010.2.713.35.
Regards,
Lubna.
I am afraid the issue has not been fixed, because the causes of its occurrence remain the same.
When you add a code block to a web page, the page parser will use a SetRenderMethodDelegate, which in turn will make the controls collection of the code block's parent read-only.
On the other hand, in order to add update panels on the fly, RadAjax inserts a dummy control before and after the control to be ajaxified. This is needed because the ajaxified control cannot be reparented (which will occur if an update panel is inserted in the page just like that). If this dummy control injection happens in a read-only control collection, you will receive the observed error.
The solution for the problem is to use code blocks inside a telerik:RadCodeBlock control, as explained in the previous posts.
Regards,
Dimo
the Telerik team
You could continue using RadAjaxManager and RadAjaxPanel controls and simply wrap all the script blocks into RadScriptBlock or RadCodeBlock controls. See the help topic below:
http://www.telerik.com/help/aspnet-ajax/ajax-radscriptblock-radcodeblock.html
All the best,
Maria Ilieva
the Telerik team
The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).
As Will and Hoventer.J saysThis error can be solved by put enclose <span runat="server"> </span>
for example <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="RadComboBox_Owner_Name">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="RadComboBox_Owner_Name" />
</UpdatedControls>
</telerik:AjaxSetting>
</telerik:RadAjaxManager >
we have to
<span runat="server">
<telerik:RadComboBox ID="RadComboBox_Owner_Name" runat="server" AllowCustomText="false" ShowMoreResultsBox="true" >
</telerik:RadComboBox> </span>
I tried on master page,radscriptblock,codeblock method nothings happen,atlast span works....
Thanks for writing......
1.-telerik:RadAjaxManager
2.-telerik:RadScriptManager
3.-telerik:RadAjaxLoadingPanel
its all
<
telerik:RadAjaxManager
ID
=
"RadAjaxManager1"
runat
=
"server"
>
<
AjaxSettings
>
<
telerik:AjaxSetting
AjaxControlID
=
"RadGrid1"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"RadGrid1"
LoadingPanelID
=
"RadAjaxLoadingPanel1"
/>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
</
AjaxSettings
>
</
telerik:RadAjaxManager
>
<
br
/>
<
telerik:RadScriptManager
ID
=
"RadScriptManager1"
runat
=
"server"
></
telerik:RadScriptManager
>
<
telerik:RadAjaxLoadingPanel
ID
=
"RadAjaxLoadingPanel1"
runat
=
"server"
Skin
=
"Telerik"
></
telerik:RadAjaxLoadingPanel
>
@Manuel Buendia
1.-telerik:RadScriptManager/asp:ScriptManager
2.-telerik:RadAjaxManager
3.-telerik:RadAjaxLoadingPanel
As per .net Framework if we used any ajax control, then we have add scriptmanager before use of any ajaxcontrol.
@Siraj
If you used "<%= %> or <%# %>" in your page then put this code in to RadcodeBlock.
1. Please put your JavaScript code in to RadCodeBlock
2. Ex: if you assign any property in to span/div/label/tr in aspx page then put this code into RadCodeBlock.
<
telerik:RadCodeBlock
ID
=
"RadCodeBlock1"
runat
=
"server"
>
<
span
>
<%= YourPropertyName %>
</
span
>
</
telerik:RadCodeBlock
>
Thanks,
Jayesh Goyani
The issue for me was that I did not have runat="server" in my form tag. Adding that fixed the problem. I was working on this for almost 2 days.
<form id="form1" runat="server">