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

Problem when I add Rad Ajax Panel

2 Answers 63 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Hamza
Top achievements
Rank 1
Hamza asked on 09 Jun 2012, 12:08 PM
Hello all :)

I add an ajax loading panel and ajax panel to my page, but when I run the page I got this message

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


what can I do to avoid it ? 

thanks all : )

2 Answers, 1 is accepted

Sort by
0
Hamza
Top achievements
Rank 1
answered on 09 Jun 2012, 12:10 PM
here is my code

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="Registration.ascx.cs"
    Inherits="Pages_Controls_Courses_Registration" %>
<telerik:RadScriptManager ID="RadScriptManager1" runat="server">
</telerik:RadScriptManager>
<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Default">
</telerik:RadAjaxLoadingPanel>
<telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" Width="900px"
    HorizontalAlign="NotSet" LoadingPanelID="RadAjaxLoadingPanel1">
    <center>
        <div style="padding: 0 0 0 0; margin: 0 0 0 0; background-color: #7f0214;">
            <table cellpadding="0" cellspacing="0" style="width: 900px;">
                <tr>
                    <td colspan="2">
                        <asp:Image ID="imgheader" runat="server" ImageUrl="~/Pics/CoursesMaster/registrationheader.PNG" />
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                          
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <telerik:RadComboBox ID="ddlmajor" runat="server" Skin="Default" OnClientSelectedIndexChanging="LoadCourses"
                            OnItemsRequested="RadComboBox1_ItemsRequested" ValidationGroup="registrationprosess796437tfvdjghd">
                        </telerik:RadComboBox>
                          
                        <telerik:RadComboBox ID="ddlcoursename" runat="server" Width="250" OnClientSelectedIndexChanging="LoadDates"
                            OnClientItemsRequested="ItemsLoaded" OnItemsRequested="RadComboBox2_ItemsRequested"
                            ValidationGroup="registrationprosess796437tfvdjghd">
                        </telerik:RadComboBox>
                          
                        <telerik:RadComboBox ID="ddldate" runat="server" OnClientItemsRequested="ItemsLoaded"
                            OnItemsRequested="RadComboBox3_ItemsRequested" ValidationGroup="registrationprosess796437tfvdjghd">
                        </telerik:RadComboBox>
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                          
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="ddlmajor"
                            ValidationGroup="registrationprosess796437tfvdjghd"></asp:RequiredFieldValidator>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="ddlcoursename"
                            ValidationGroup="registrationprosess796437tfvdjghd"></asp:RequiredFieldValidator>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="ddldate"
                            ValidationGroup="registrationprosess796437tfvdjghd"></asp:RequiredFieldValidator>
                    </td>
                </tr>
                <tr>
                    <td>
                        <table cellpadding="0" cellspacing="0" style="width: 400px;">
                            <tr>
                                <td>
                                    <telerik:RadTextBox ID="txtmail" runat="server" EmptyMessage="Your Mail" LabelWidth="64px"
                                        Width="160px" Height="25px" ValidationGroup="loginvalidationgroup784326fhj">
                                    </telerik:RadTextBox
                                </td>
                                <td>
                                    <telerik:RadTextBox ID="txtPassword" runat="server" EmptyMessage="Password" Height="25px"
                                        LabelWidth="64px" Width="160px" TextMode="Password" ValidationGroup="loginvalidationgroup784326fhj">
                                    </telerik:RadTextBox
                                </td>
                                <td>
                                    <telerik:RadButton ID="btnlogin" runat="server" Text="Log In" Height="25px" OnClick="btnlogin_Click"
                                        ValidationGroup="loginvalidationgroup784326fhj">
                                    </telerik:RadButton>
                                </td>
                            </tr>
                        </table>
                    </td>
                    <td rowspan="5" style="width: 500px;">
                        <asp:Label ID="lblSummary" runat="server" ForeColor="White" CssClass="FontNormal"></asp:Label>
                    </td>
                </tr>
                <tr>
                    <td style="width: 400px;">
                         <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="txtPassword"
                            ValidationGroup="loginvalidationgroup784326fhj"></asp:RequiredFieldValidator>
                        <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="txtmail"
                            ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" ValidationGroup="loginvalidationgroup784326fhj"></asp:RegularExpressionValidator>
                          
                    </td>
                </tr>
                <tr>
                    <td style="width: 400px;">
                        <telerik:RadTextBox ID="txtnotes" runat="server" EmptyMessage="Write some notes here!"
                            LabelWidth="64px" MaxLength="2000" TextMode="MultiLine" Width="391px" Height="200px"
                            ValidationGroup="registrationprosess796437tfvdjghd">
                        </telerik:RadTextBox>
                    </td>
                </tr>
                <tr>
                    <td>
                          
                    </td>
                </tr>
                <tr>
                    <td style="width: 400px;">
                        <telerik:RadButton ID="btnreview" runat="server" Text="Review" Width="190px" ValidationGroup="registrationprosess796437tfvdjghd"
                            OnClick="btnreview_Click">
                        </telerik:RadButton>
                          
                        <telerik:RadButton ID="btnSubmitreg" runat="server" Text="Submit" Width="190px" ValidationGroup="registrationprosess796437tfvdjghd"
                            OnClick="btnSubmitreg_Click">
                        </telerik:RadButton>
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                          
                    </td>
                </tr>
            </table>
        </div>
    </center>
</telerik:RadAjaxPanel>
<script type="text/javascript">
    var ddlcoursenamevar;
    var ddldatevar;
 
    function pageLoad() {
        ddlcoursenamevar = $find("<%= ddlcoursename.ClientID %>");
        ddldatevar = $find("<%= ddldate.ClientID %>");
    }
 
    function LoadCourses(sender, eventArgs) {
        var item = eventArgs.get_item();
        ddlcoursenamevar.set_text("Loading...");
        ddldatevar.clearSelection();
 
        if (item.get_index() > 0) {
            ddlcoursenamevar.requestItems(item.get_value(), false);
        }
        else {
            ddlcoursenamevar.set_text(" ");
            ddlcoursenamevar.clearItems();
 
            ddldatevar.set_text(" ");
            ddldatevar.clearItems();
        }
    }
 
    function LoadDates(sender, eventArgs) {
        var item = eventArgs.get_item();
 
        ddldatevar.set_text("Loading...");
        ddldatevar.requestItems(item.get_value(), false);
    }
 
    function ItemsLoaded(sender, eventArgs) {
        if (sender.get_items().get_count() > 0) {
            sender.set_text(sender.get_items().getItem(0).get_text());
            sender.get_items().getItem(0).highlight();
        }
 
        sender.showDropDown();
    }
     
    </script>
0
Eyup
Telerik team
answered on 12 Jun 2012, 02:52 PM
Hello Hamza,

You will need to wrap your script declaration in either RadCodeBlock or RadScriptBlock in order to allow server and client script to work well together with AJAX updates. The described solution is demonstrated in the following help topic:
RadCodeBlock and RadScriptBlock Overview

All the best,
Eyup
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Ajax
Asked by
Hamza
Top achievements
Rank 1
Answers by
Hamza
Top achievements
Rank 1
Eyup
Telerik team
Share this question
or