This is a migrated thread and some comments may be shown as answers.

[Solved] The Controls collection cannot be modified because the control contains code blocks

6 Answers 391 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Greg
Top achievements
Rank 1
Greg asked on 13 Feb 2008, 06:48 AM
Hi,

I am using Prometheus v2007.3.1314.35, and have come across this error when using the RadAjaxManager and text from our ASP.NET App_GlobalResources\Resource.resx file.

Within the Resource.resx file I have a key btnSubmit with text value "Submit".
The text is displayed within the submit button correctly, & within the UpdatePanel, but if I try to use any Resource text on the page before or after the RadAjaxManager an error is thrown.

Here is the code to replicate the error.

For the page to work remove:
(Some Text outside asp:UpdatePanel "<%= Resources.Resource.btnSubmit %>")

<

asp:ScriptManager ID=ScriptManager1 runat=server />

<p />

Some Text outside asp:UpdatePanel "<%= Resources.Resource.btnSubmit %>"

<p />

 

<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">

<AjaxSettings>

<telerik:AjaxSetting AjaxControlID="updPanel1">

<UpdatedControls>

<telerik:AjaxUpdatedControl ControlID="updPanel1" LoadingPanelID="RadAjaxLoadingPanel1" />

</UpdatedControls>

</telerik:AjaxSetting>

</AjaxSettings>

</telerik:RadAjaxManager>

<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Transparency="30" BackColor="#E0E0E0" InitialDelayTime="500">

<asp:Image ID="Image1" runat="server" ImageUrl="~/images/icons/loading.gif" BorderWidth="0px" AlternateText="Loading" ></asp:Image>

</telerik:RadAjaxLoadingPanel>

<asp:UpdatePanel ID="updPanel1" runat="server" UpdateMode=Conditional ChildrenAsTriggers=true >

<ContentTemplate>

<p />

<asp:Label ID=Label1 runat=server Text="Button Clicked at " />

<p />

<asp:Button ID=Button1 runat=server OnClick="Button1_Click" Text="<%$ Resources:Resource,btnSubmit %>" />

<p />

Same Text within asp:UpdatePanel "<%= Resources.Resource.btnSubmit %>"

</ContentTemplate>

</asp:UpdatePanel>

Any Ideas?
Thanks

6 Answers, 1 is accepted

Sort by
0
Sebastian
Telerik team
answered on 13 Feb 2008, 09:26 AM
Hi William,

To avoid the exception when using server tags for expression evaluation outside of the MS UpdatePanel, you will need to wrap your code in RadCodeBlock. Additional information on this subject and the RadCodeBlock control usage can be found in the online documentation here.

Best regards,
Stephen
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Greg
Top achievements
Rank 1
answered on 13 Feb 2008, 12:26 PM

Hi Stephen,

 To internationalise our app we have all our display text / labels within a global Resource.resx file.

 This text is not code nor control ID’s, but text for labels, buttons and general display, which is not hidden as with script variables on the page.

 This display text is placed throughout our site using the standard resource expression <%= %> and <%$ %>

 An example would be

 <table cellpadding="2" cellspacing="0" border="0" width="100%" >

<tr>

<td class="textBold" width="25%"><%= Resources.Resource.lblCountry %>:</td>

<td width="35%">

<telerik:radcombobox

                                id="rcbCountry"

                                Runat="server"

                                Height="150px"

                                Width="250px"

                                Skin="Office2007"

                                accessKey="T"

                                MarkFirstMatch="True"

                                AllowCustomText="False"

                                RadControlsDir="/">

                            </telerik:radcombobox>

</td>

<td align="right">

<asp:button id="btnSave" text="<%$ Resources:Resource,btnSave%>" cssclass="btn" OnClick=”btnSave_Click” runat="server" />

&nbsp; &nbsp;

<asp:button id="btnCancel" text="<%$ Resources:Resource,btnCancel %>" cssclass="btn" runat="server" />

</td>

</tr>

</table>

 It would be too extensive to place the RadCodeBlock around each instance, and probably not possible with resource expressions within ASP.NET controls such as buttons and labels.

 The update Panel works correctly by itself, or with a normal AJAXToolKit UpdatePanelAnimation.

It is only when the RadAjaxManager & RadAjaxLoadingPanel is used on the page that this error occurs.

 Here is a MSDN link that describes Explicit localization using Global Resource files. http://msdn2.microsoft.com/en-us/library/ms227427.aspx

 It would be great if there was another way around this.

Thanks
William

0
Steve
Telerik team
answered on 15 Feb 2008, 01:57 PM
Hello William,

Indeed you are right that it would be too extensive to place RadCodeBlock around each instance of code blocks you have in your app, but unfortunately the mixture of dynamically created UpdatePanels and code blocks does not get along well by the ASP.NET page parser. We will be looking for a way to remove this limitation, but for the time being the usage of RadCodeBlock is necessary.

Sorry for the inconvenience.

Greetings,
Steve
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Chris
Top achievements
Rank 1
answered on 30 Oct 2008, 08:57 PM
Any update on this?  I am attempting the same thing as William.  I've tried to add the necessary Telerik control, but it doesn't work.  I still get the same error.  Thanks.

Chris
0
Sebastian
Telerik team
answered on 31 Oct 2008, 07:45 AM
Hello Christopher,

I suppose you already familiarized yourself with the content from the help article linked in my first reply as well as with the relevant paragraph from this documentation article. If you still experience the issue, please isolate a working subset of your project and send it enclosed to a formal support ticket. We will test/debug it locally and will get around to you with our findings.
 
Best regards,
Stephen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
rtk
Top achievements
Rank 1
answered on 24 Jul 2009, 01:41 PM
Hei

In that case, why would this work:-)
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
        
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
     <ContentTemplate>
          <%= Resources.Resource1.profile%>
     </ContentTemplate>            
</asp:UpdatePanel>
Tags
Ajax
Asked by
Greg
Top achievements
Rank 1
Answers by
Sebastian
Telerik team
Greg
Top achievements
Rank 1
Steve
Telerik team
Chris
Top achievements
Rank 1
rtk
Top achievements
Rank 1
Share this question
or