
Source: | System.Web |
Message: | Exception of type 'System.Web.HttpUnhandledException' was thrown. |
Inner Exception: | The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>). |
Stack Trace: | at System.Web.UI.ControlCollection.AddAt(Int32 index, Control child) at Telerik.Web.UI.RadAjaxControl.MoveUpdatePanel(Control initiator, Control updated) at Telerik.Web.UI.RadAjaxControl.PerformRender() at Telerik.Web.UI.RadAjaxControl.OnPageRender(HtmlTextWriter writer, Control page) at Telerik.Web.UI.RadAjaxControl.RenderPageInAjaxMode(HtmlTextWriter writer, Control page) at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) at System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) at System.Web.UI.Page.Render(HtmlTextWriter writer) at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) at System.Web.UI.Control.RenderControl(HtmlTextWriter writer) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) |
Form: | |
Query String: | |
Target Site: | Boolean HandleError(System.Exception) |
All i have done is change the radA:RadAjaxPanel to telerik:RadAjaxPanel. I also added the <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> tag to the top of the page. I also put a ScriptManager on the page. Is there something I missed?
Thanks, Jason
52 Answers, 1 is accepted

Try removing the runat=server from the <head> tag in your document.
I've just resolved this with a standard RAD ASP.NET control.
Rich
If you have any code blocks you can enclose them using telerik:RadCodeBlock tag.
Best regards,
Vlad
the telerik team
Instantly find answers to your questions at the new Telerik Support Center

Thanks... Jason

<telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server"> | |
<asp:Label ID="noAvatarWarn" runat="server" /> | |
<asp:Image ID="avatar" runat="server" /> | |
<asp:Image ID="offlineAvatar" runat="server" /> | |
<asp:Button ID="Button2" runat="server" Text="Button" SkinID="hiddenbutton" /> | |
</telerik:RadAjaxPanel> |
by the way, I originally coded this part with RadAjaxPanel, and everything worked fine.
Do you have "Theme" applied on your page - this may cause such exception. You can post the entire page declaration to give you more to-the-point explanation.
Best regards,
Vlad
the telerik team
Instantly find answers to your questions at the new Telerik Support Center

The page is in nested masterpages (2) as well. The only relevant thing is
<asp:Button runat="server" CssClass="hiddenButtons" skinId="hiddenbutton" />
as in the skin file. I don't apply skin to the telerik.radajaxpanel.
The page is too huge to post on the forum.
I tried to replicate this unfortunately to no avail - it seems that the source of the problem is somewhere else. You can find small demo attached.
Sincerely yours,
Vlad
the telerik team
Instantly find answers to your questions at the new Telerik Support Center

I did try enclosing the script block I have with RadCodeBlock but it still does not work (same error message).
What about script blocks in the masterpage? Do I have to worry about those?
Yes, you must enclose those code blocks within telerik:RadCodeBlock tag. If that does not help, would you please isolate the issue as much as possible and send the code via support ticket?
Thank you in advance for your cooperation.
Kind regards,
Konstantin Petkov
the telerik team
Instantly find answers to your questions at the new Telerik Support Center

Can you take a moment and explain why RadCodeBlocks are necessary with the new "Prometheus" RadAjax? I don't think the documentation has much on these new controls yet and they seem to be a point of confusion.
Thanks~
Todd

The way script blocks are implemented in ASP.NET may interfere with ajax manager's render interception mechanism. Тhat is why we have created the workaround of enclosing script blocks in a RadCodeBlock control. Moving scripts inside a RadCodeBlock control will isolate the effects to that control only and the partial rendering code will not be affected.
Sam, please enclose all those scripts in RadCodeBlock even at your MasterPage/WebUserControl.
Kind regards,
Konstantin Petkov
the telerik team
Instantly find answers to your questions at the new Telerik Support Center


for example:
window["<%= rgdContactPerson.ClientID %>"].AjaxRequest("<%= rgdContactPerson.UniqueID %>", "CloseForm");
Thanks!
Here is an example:
<head runat="server"> |
<telerik:RadCodeBlock runat="server"> |
<script type="text/javascript"> |
function MyFunction () |
{ |
} |
</script> |
</telerik:RadCodeBlock> |
</head> |
Regards,
Albert
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center

must be applied to any javascript that is dealing with telerik prometheus controls. Is it correct
Yes, this information is correct. Generally speaking, you should wrap any client-side code which contains server tags in RadScriptBlock. Review paragraph 6 of this help article for more info.
Best regards,
Stephen
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center

Unfortunately I have to agree with you -- this task is quite tedious in case of plenty of pages containing server code blocks. We will once again look into that and try to find another workaround.
Please, excuse us for the inconvenience.
Kind regards,
Konstantin Petkov
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center

RadAjaxPanel1.ResponseScripts.Add(
string.Format("hideDropDowns();"));
function hideDropDowns()
{
var ddlIDs = document.getElementById('<%= dropDownListIDs.ClientID %>');
var ids = ddlIDs.value.split(',');
for( var i = 0 ; i < ids.length ; i++)
{
if( ids[i] != '')
{
try {
var currentDropDown = document.getElementById(ids[i]);
currentDropDown.style.display =
"none";
currentDropDown.style.visibility =
"hidden";
}
catch(e) {};
}
}
}
Can you elaborate on what do you mean by "I got my page to run by blocking out the javascript, but now the javascript seems to run after the AJAX runs"?
All the best,
Steve
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center

<
telerik:RadCodeBlock runat="server">
<
script language="javascript" type="text/javascript">
<!--
function displayDropDown(timeTypeDD, projectDD, sctsDD, otherDD)
{
var ddlIDs = document.getElementById('<%# dropDownListIDs.ClientID %>');
var selectedValue = timeTypeDD.value;
if (selectedValue == 1) {
projectDD.style.display =
"inline";
projectDD.style.visibility =
"visible";
projectDD.focus();
sctsDD.style.display =
"none";
sctsDD.style.visibility =
"hidden";
otherDD.style.display =
"none";
otherDD.style.visibility =
"hidden";
}
else if (selectedValue == 2) {
projectDD.style.display =
"none";
projectDD.style.visibility =
"hidden";
sctsDD.style.display =
"inline";
sctsDD.style.visibility =
"visible";
sctsDD.focus();
otherDD.style.display =
"none";
otherDD.style.visibility =
"hidden";
}
else if (selectedValue == 3) {
projectDD.style.display =
"none";
projectDD.style.visibility =
"hidden";
sctsDD.style.display =
"none";
sctsDD.style.visibility =
"hidden";
otherDD.style.display =
"inline";
otherDD.style.visibility =
"visible";
otherDD.focus();
}
}
function hideDropDowns()
{
var ddlIDs = document.getElementById('<%= dropDownListIDs.ClientID %>');
var ids = ddlIDs.value.split(',');
for( var i = 0 ; i < ids.length ; i++)
{
if( ids[i] != '')
{
try {
var currentDropDown = document.getElementById(ids[i]);
currentDropDown.style.display =
"none";
currentDropDown.style.visibility =
"hidden";
}
catch(e) {};
}
}
}
function focusCategory(categoryDD)
{
categoryDD.focus();
}
-->
</
script>
</
telerik:RadCodeBlock>
Unfortunately I was not able to reproduce your problem. I am attaching a sample project illustrating my approach to this forum post. Please tell us if we omitted something from your logic - this can lead us to the source of the issue to eliminate it accordingly.
Kind regards,
Iana
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center



I will build a demo app and create a new support ticket.
Thanks,
Allan

ASP.NET AJAX (formerly "Prometheus") is causing me problems. My site worked fine before I upgraded, but now some pages seem unable to load because of the error noted in this thread. Not all of my pages, but most of them. Some pages that have the RadAjaxManager seem to work fine, but others do not. Here is the call stack associated with this 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) +2108046 |
Telerik.Web.UI.RadAjaxControl.MoveUpdatePanel(Control initiator, Control updated) +171 |
Telerik.Web.UI.RadAjaxControl.PerformRender() +373 |
Telerik.Web.UI.RadAjaxControl.OnPageRender(HtmlTextWriter writer, Control page) +1309 |
Telerik.Web.UI.RadAjaxControl.RenderPageInAjaxMode(HtmlTextWriter writer, Control page) +152 |
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +98 |
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +20 |
System.Web.UI.Page.Render(HtmlTextWriter writer) +26 |
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +25 |
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +121 |
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +22 |
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2558 |
I find that the "workaround" you posted concerning the RadCodeBlock tag fixes my problem. This is completely unacceptable, as noted by Konstantin Petkov in the post of 1/4/2008 1:31:07 AM below. Konstantin acknowledged the unacceptable nature of this solution in early January, nearly four months ago, and still no solution has been found. This, also, is unacceptable.
I'm finding that my code works fine if I delete RadAjaxManager from the page. That seems like an odd solution for a set of controls that has AJAX in the name.
Should I just go back to the old version of the controls? Why then did I pay the subscription price?
Many of the controls no longer allow server code blocks (like window["<%=RadGrid1.ClientID%>"]) inside scripts residing in page head tag -- from now on they register their CSS files into page header. You need to either wrap the script inside additional PlaceHolder or move it into the page body instead. Nevertheless, I have passed your comments to our developers, for further consideration. Any additional details as to why you find the use of RadCodeBlock unacceptable would be appreciated.
Regards,
Yavor
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center

However, I still have some issues with this whole situation. Asking us to move <script> blocks out of the <head> is not an acceptable solution. <script> blocks belong in the <head>, that's how HTML is set up.
Telling us we can't use code blocks (<% %>) in our scripts is not acceptable either. You're saying that your ASP.NET AJAX controls don't support ASP.NET. If that's the case, then you really can't call them ASP.NET controls, can you?
Also, every example of the RadAjaxLoadingPanel I've seen on your site uses code blocks (<%= RadAjaxLoadingPanel.GetWebResourceUrl(Page, "Telerik.Web.UI.Skins.Default.Ajax.loading.gif") %>). If the RadAjaxManager is having trouble with code blocks, why is your RadAjaxLoadingPanel using them? All of your other controls seem to be able to find their images in the Telerik.dll file without using code blocks. Why does the RadAjaxLoadingPanel seem to be unable to do this? And do I need to wrap that code block in <RadCodeBlock> tags?
At this point I can get by with the <RadCodeBlock> tags in my code. I don't use many code blocks, since I try to follow the ASP.NET programming model of separating UI from business logic. Still, ASP.NET code blocks are an integral part of ASP.NET programming, as Telerik has demonstrated in the use of them in the RadAjaxLoadingPanel. I do hope that this issue gets resolved soon.
Thanks -
Brad
Thank you for your feedback.
I will pass it along to our development team. They will definately review it carefully, and consider a modification of the control for one of the upcoming versions.
Kind regards,
Yavor
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center

David

</rant>

At the moment my JS code is like:
var ajaxManagerObject = window["<%= rAjax.ClientID %>"]; // Locate AJAX Object
But perhaps there is a better way for future?
cheers
ewart
Better approach might be to use the $find method of the ASP.NET AJAX framework which is a shortcut for the findComponent() method. Review the code snippets from this topic in the online documentation for more info (it also outlines the changes we made compared to the Prometheus version of RadAjax):
http://www.telerik.com/help/aspnet-ajax/ajxmigration.html
Best regards,
Stephen
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center

I'm also having the same trouble like Jason with the exception 'The controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>)' and I'm wordking in the 2008 Q1 HotFix.
I'm also using DotNetNuke which headers or code blocks I do not whish to touch. Everything worked fine with 2007 Q3...
Thanks in advance.
At present, the only possibility to remove this exception is to wrap the relevant JavaScript code in a RadCodeBlock. I hope that this approach does not cause you any inconvenience.
Regards,
Yavor
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center

Like I said: a developer is not always able to change third party scripts.
Please inform me of any improvements on this issue.
I'm afraid there is misunderstanding here. You don't have to change anything in the third-party control scripts. The error is resolved simply by wrapping anything containing the code block within RadCodeBlock. It won't change anything else either in the layout or in the modules functionality. The RadCodeBlock and RadScriptBlock are described in details here.
I hope this helps.
Sincerely yours,
Konstantin Petkov
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center

1. I use the Telerik controls within a DotNetNuke module. DNN uses script blocks which I don't want to change.
2. I don't use any code or script blocks myself (just Telerik controls like RadGrid, RadComboBox)
3. Version 2007 Q3 worked fine
4. Version 2008 Q1 gives me the 'The Controls collection cannot be modified...' error
This is the issue I was complaining about. At first, I understood that I needed to encapsulate the script DNN script blocks with RadScriptBlock, but now you say I 'don't have to change anything in the third-party control scripts'?
Please inform me about any misinterpretations and what I should do to get rid of this error.
Thanks,
Willem
What I meant is to wrap those code blocks you have in the header within RadCodeBlock to resolve the error. It won't change anything in the functionality as well as in the layout.
Alternatively, you can try disabling the page head update through the EnablePageHeadUpdate="false" RadAjaxControl setting.
Let us know whether this works for you.
Greetings,
Konstantin Petkov
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center

Thank you for your swift response.
You cannot avoid changing the DNN module source. Have you tried EnablePageHeadUpdate="false" suggestion?
Sincerely yours,
Konstantin Petkov
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center

<
input class="norm" id="btnLookup1" onclick= "openLookupWindow('<%= ddlSearchField1.ClientID %>','<%= txtTerm1.ClientID %>');" type="button" value="..."/>
There is an AJAX manager on the page and the usual error occurs because of this line.
Thanks

Bodevain

Thanks... Eleni

i have a radcombobox and a text box .

- First, make sure that your Combobox works with a PostBack. If it works with a normal PostBack, it should continue to work when you add the "ajaxification."
- Second, one thing often overlooked with Combobox is the AutoPostBack property. Make sure AutoPostBack property is set to true on your RadCombobox to ensure a server event is fired when an action is performed.

- First, make sure that your Combobox works with a PostBack. If it works with a normal PostBack, it should continue to work when you add the "ajaxification."
- Second, one thing often overlooked with Combobox is the AutoPostBack property. Make sure AutoPostBack property is set to true on your RadCombobox to ensure a server event is fired when an action is performed.


I have the same problem .........
I am filling other combo on selected index change of another combo that combo not updated
kindly let me know if you got answer

Thanks
Rama

Basically, the built-in template has a header like this:
<
head
runat
=
"server"
>
<
title
><%: Page.Title %> - My Site</
title
>
<
meta
charset
=
"utf-8"
/>
<
meta
name
=
"viewport"
content
=
"width=device-width"
/>
<
asp:PlaceHolder
runat
=
"server"
>
<%: Scripts.Render("~/bundles/modernizr") %>
</
asp:PlaceHolder
>
<
webopt:BundleReference
runat
=
"server"
Path
=
"~/Content/css"
/>
<
link
href
=
"~/favicon.ico"
rel
=
"shortcut icon"
type
=
"image/x-icon"
/>
<
asp:ContentPlaceHolder
runat
=
"server"
ID
=
"HeadContent"
/>
</
head
>
<
head
runat
=
"server"
>
<
telerik:RadCodeBlock
runat
=
"server"
>
<
title
><%: Page.Title %> - My Site</
title
>
</
telerik:RadCodeBlock
>
<
meta
charset
=
"utf-8"
/>
<
meta
name
=
"viewport"
content
=
"width=device-width"
/>
<
telerik:RadCodeBlock
runat
=
"server"
>
<
asp:PlaceHolder
runat
=
"server"
>
<%: Scripts.Render("~/bundles/modernizr") %>
</
asp:PlaceHolder
>
</
telerik:RadCodeBlock
>
<
telerik:RadCodeBlock
runat
=
"server"
>
<
webopt:BundleReference
runat
=
"server"
Path
=
"~/Content/css"
/>
</
telerik:RadCodeBlock
>
<
link
href
=
"~/favicon.ico"
rel
=
"shortcut icon"
type
=
"image/x-icon"
/>
<
asp:ContentPlaceHolder
runat
=
"server"
ID
=
"HeadContent"
/>
</
head
>
So then you realize you have to retrain all developers to NEVER use any standard built-in ASP.NET syntax such as "<%:" or "<%=", etc. Then you realize, this doesn't make any sense, and you say to yourself: "I noticed that the placeholder control had a "runat=server" and without wrapping that control in a RadCodeBlock, everything worked just fine!".
Ahh, so now the solution presents itself. All we need are server controls wrapping the elements giving us this problem! But, I don't want to wrap my "title" and all my "H1-H6" tags with asp:Panel controls either! So, here it is, the solution to all this mess...
simply set your elements to run from the server (ex. title runat='server').
And finally, the head tag which works with RadAjax!
<
head
runat
=
"server"
>
<
title
runat
=
"server"
><%: Page.Title %> - My Site</
title
>
<
meta
charset
=
"utf-8"
/>
<
meta
name
=
"viewport"
content
=
"width=device-width"
/>
<
asp:PlaceHolder
runat
=
"server"
>
<%: Scripts.Render("~/bundles/modernizr") %>
</
asp:PlaceHolder
>
<
webopt:BundleReference
runat
=
"server"
Path
=
"~/Content/css"
/>
<
link
href
=
"~/favicon.ico"
rel
=
"shortcut icon"
type
=
"image/x-icon"
/>
<
asp:ContentPlaceHolder
runat
=
"server"
ID
=
"HeadContent"
/>
</
head
>
And viola! No RadCodeBlocks!!!
Now, this may not work in all situations, but it has saved me from over-complicating the simplest things in my site.