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

Show me the error on Scheduler - Resource Grouping The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>

3 Answers 62 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
aakash
Top achievements
Rank 1
aakash asked on 05 Mar 2018, 07:18 AM

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

 

Here is code in my aspx page.

<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/MasterPage/iCRAMaster.Master" CodeBehind="ScheduleAppointment.aspx.cs" Inherits="iCRA_UI.FieldTech.ScheduleAppointment" %>

<%@ Register TagPrefix="telerik" Namespace="Telerik.QuickStart" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>



<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
 
    <script src="lib/qsf.js"></script>
    <link href="lib/qsf.css" rel="stylesheet" />
    </asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
   

 <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
    <telerik:RadSkinManager ID="RadSkinManager1" runat="server" ShowChooser="true" />

     <telerik:RadWindowManager RenderMode="Lightweight" ID="RadWindowManager1" runat="server" EnableShadow="true">
        </telerik:RadWindowManager>

    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadScheduler1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadScheduler1" LoadingPanelID="RadAjaxLoadingPanel1"></telerik:AjaxUpdatedControl>
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="ConfigurationPanel1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadScheduler1" LoadingPanelID="RadAjaxLoadingPanel1"></telerik:AjaxUpdatedControl>
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server">
    </telerik:RadAjaxLoadingPanel>
    <telerik:RadAjaxPanel runat="server" ID="RadAjaxPanel1" LoadingPanelID="RadAjaxLoadingPanel1">
        <div class="demo-container no-bg">
            <telerik:RadScheduler RenderMode="Lightweight" runat="server" ID="RadScheduler1" GroupBy="Speaker" GroupingDirection="Horizontal"
                OnNavigationCommand="RadScheduler1_NavigationCommand" 
                AppointmentStyleMode="Default" DataSourceID="EventsDataSource" DataKeyField="ID"
                FirstDayOfWeek="Friday" LastDayOfWeek="Sunday" DataSubjectField="Description"
                DataStartField="StartTime" DataEndField="EndTime" DataRecurrenceField="RecurrenceRule"
                SelectedView="DayView" DataRecurrenceParentKeyField="RecurrenceParentID" AllowInsert="true" OnAppointmentUpdate="RadScheduler1_AppointmentUpdate" OnAppointmentDelete="RadScheduler1_AppointmentDelete"  OnAppointmentInsert="RadScheduler1_AppointmentInsert" OnResourceHeaderCreated="RadScheduler1_ResourceHeaderCreated"
               
                OverflowBehavior="Auto">
                <AdvancedForm Modal="true"></AdvancedForm>
                <MonthView UserSelectable="false"></MonthView>
                <TimelineView />
                <ResourceHeaderTemplate>
                    <asp:Panel ID="ResourceImageWrapper" runat="server" CssClass="ResCustomClass">
                        <asp:Image ID="SpeakerImage" runat="server" AlternateText='<%# Eval("Text") %>'></asp:Image>
                    </asp:Panel>
                </ResourceHeaderTemplate>
                <ResourceTypes>
                    <telerik:ResourceType KeyField="UserID" Name="Speaker" TextField="Fullname" ForeignKeyField="UserID"
                        DataSourceID="SpeakersDataSource1"></telerik:ResourceType>
                </ResourceTypes>
                <ResourceStyles>
                    <telerik:ResourceStyleMapping Type="Speaker" Key="1" BackColor="#eb901b"></telerik:ResourceStyleMapping>
                    <telerik:ResourceStyleMapping Type="Speaker" Key="2" BackColor="#8fd21b"></telerik:ResourceStyleMapping>
                    <telerik:ResourceStyleMapping Type="Speaker" Key="3" BackColor="#278ce9"></telerik:ResourceStyleMapping>
                    <telerik:ResourceStyleMapping Type="Speaker" Key="4" BackColor="#f14db2"></telerik:ResourceStyleMapping>
                </ResourceStyles>
                <TimeSlotContextMenuSettings EnableDefault="true"></TimeSlotContextMenuSettings>
                <AppointmentContextMenuSettings EnableDefault="true"></AppointmentContextMenuSettings>
            </telerik:RadScheduler>
        </div>
    </telerik:RadAjaxPanel>
    <asp:SqlDataSource ID="SpeakersDataSource1" runat="server"
        ConnectionString="<%$ ConnectionStrings:SQL %>" SelectCommand="SELECT * FROM [user_view]"
        >
    </asp:SqlDataSource>

          <asp:SqlDataSource ID="SpeakersDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:myConnectionString %>" SelectCommand="SELECT * FROM [sp_view]"></asp:SqlDataSource>
    <asp:SqlDataSource ID="EventsDataSource" runat="server"
        ConnectionString="<%$ ConnectionStrings:myConnectionString %>"
        SelectCommand="SELECT * FROM [sp_view]" InsertCommand="INSERT INTO [sp_view] ([Description], [StartTime], [EndTime], [SpeakerID]) VALUES (@Description, @Start, @End, @SpeakerID)"
       UpdateCommand="UPDATE [sp_view] SET [Description] = @Description, [Start] = @Start, [End] = @End, [RoomID] = @RoomID, [RecurrenceRule] = @RecurrenceRule, [RecurrenceParentID] = @RecurrenceParentID, [UserID] = @SpeakerID WHERE [UserID] = @ID"
        DeleteCommand="DELETE FROM [sp_view] WHERE [UserID] = @ID">
        <DeleteParameters>
            <asp:Parameter Name="ID" Type="Int32"></asp:Parameter>
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="Description" Type="String"></asp:Parameter>
            <asp:Parameter Name="Start" Type="DateTime"></asp:Parameter>
            <asp:Parameter Name="End" Type="DateTime"></asp:Parameter>
            <asp:Parameter Name="RoomID" Type="Int32" DefaultValue="1"></asp:Parameter>
            <asp:Parameter Name="RecurrenceRule" Type="String"></asp:Parameter>
            <asp:Parameter Name="RecurrenceParentID" Type="Int32"></asp:Parameter>
            <asp:Parameter Name="SpeakerID" Type="Int32"></asp:Parameter>
            <asp:Parameter Name="ID" Type="Int32"></asp:Parameter>
        </UpdateParameters>
     <InsertParameters>
            <asp:Parameter Name="Description" Type="String"></asp:Parameter>
            <asp:Parameter Name="Start" Type="DateTime"></asp:Parameter>
            <asp:Parameter Name="End" Type="DateTime"></asp:Parameter>
            <asp:Parameter Name="RoomID" Type="Int32" DefaultValue="1"></asp:Parameter>
            <asp:Parameter Name="RecurrenceRule" Type="String"></asp:Parameter>
            <asp:Parameter Name="RecurrenceParentID" Type="Int32"></asp:Parameter>
            <asp:Parameter Name="SpeakerID" Type="Int32"></asp:Parameter>
        </InsertParameters>
    </asp:SqlDataSource>
 

 
    </asp:Content>

what am doing wrong?

3 Answers, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 05 Mar 2018, 12:32 PM
Hi there,

I see that you are loading a script file inside the head of the page:

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
  
    <script src="lib/qsf.js"></script>
    <link href="lib/qsf.css" rel="stylesheet" />
</asp:Content>
 


Can you move this script tag to the body element or wrap it inside RadCodeBlock?

You can find more information on the subject in this article: Error message, "The Controls collection cannot be modified because the control contains code blocks".

Regards,
Rumen
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
aakash
Top achievements
Rank 1
answered on 05 Mar 2018, 01:19 PM

its not working its give me the same error  

collection cannot be modified because the control contains code blocks (i.e. <% ... %>

 

Regards 

aakash

0
Rumen
Telerik team
answered on 05 Mar 2018, 03:12 PM
Hello,

Wrap the Eval inside the ResourceHeaderTemplate template in RadCodeBlock as demonstrated in this forum post example:

https://www.telerik.com/forums/export-error-from-grid-due-to-code-blocks#NnDfKC_9-U2BRjfBQ9TfTQ

<ResourceHeaderTemplate>
         <telerik:RadCodeBlock runat="server" ID="RadCodeBlock1">
                    <asp:Panel ID="ResourceImageWrapper" runat="server" CssClass="ResCustomClass">
                        <asp:Image ID="SpeakerImage" runat="server" AlternateText='<%# Eval("Text") %>'></asp:Image>
                    </asp:Panel>
         </telerik:RadCodeBlock>
</ResourceHeaderTemplate>


Best regards,
Rumen
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Ajax
Asked by
aakash
Top achievements
Rank 1
Answers by
Rumen
Telerik team
aakash
Top achievements
Rank 1
Share this question
or