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

Problem using RadListBox inside RadAjaxPanel

2 Answers 108 Views
AjaxPanel
This is a migrated thread and some comments may be shown as answers.
Hagai
Top achievements
Rank 1
Veteran
Hagai asked on 26 Dec 2019, 11:15 AM

Hi there,

 

I'm trying to use RadlistBox with custom item template under RadAjaxPanel where my page is a webform which use a MasterPage file.

And I'm receiving the following error:

Server Error in '/' Application.

The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:

[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) +9812992 Telerik.Web.UI.RadAjaxControl.MoveUpdatePanel(Control initiator, Control updated) +142 [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) +190 Telerik.Web.UI.RadAjaxControl.PerformRender() +405 Telerik.Web.UI.RadAjaxControl.OnPageRender(HtmlTextWriter writer, Control page) +1187 Telerik.Web.UI.RadAjaxControl.RenderPageInAjaxMode(HtmlTextWriter writer, Control page) +75 System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +270 System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +14 System.Web.UI.Page.Render(HtmlTextWriter writer) +30 System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +67 System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +101 System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +27 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1342

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.8.3752.0

 

How can I solved it? below is my asp.net webform  declaration.

 

Looking forward to your earliest reply,

Thanks,

Hagai.

<telerik:RadAjaxPanel ID="RadAjaxPanelPublications" runat="server">
   <telerik:RadListBox ID="RadListBoxPublications" runat="server" AllowReorder="True" EnableDragAndDrop="True" SelectionMode="Multiple" Width="98%" Height="700px">      
       <ItemTemplate>           
           <div class="row">
               <div class="col-md-9">
                   <div dir="<%# (DataBinder.GetDataItem(Container) as Idc.FacultySites.Models.Publication).Language == Idc.FacultySites.Models.Publication.LanguageName.Hebrew? "rtl" : "ltr" %>"
                       class="<%# (DataBinder.GetDataItem(Container) as Idc.FacultySites.Models.Publication).Language == Idc.FacultySites.Models.Publication.LanguageName.Hebrew? "text-right-fix" : "text-left-fix" %>">
                       <a id="PublicationLink" runat="server">
                           <%# (DataBinder.GetDataItem(Container) as Idc.FacultySites.Models.Publication).Text %>
                       </a>
                   </div>
               </div>
               <div class="col-md-1"> </div>
               <div class="col-md-2">
                   <div class="row">
                       <div class="col-md-2">
                           <telerik:RadButton ID="RadButtonEditPublication" runat="server" RenderMode="Lightweight" ToolTip="<%$ Resources:FacultySites, Edit%>" CommandArgument="<%# (DataBinder.GetDataItem(Container) as Idc.FacultySites.Models.Publication).Id %>" OnCommand="RadButtonEditPublication_Command">
                               <ContentTemplate>
                                   <span class="glyphicon glyphicon-edit"></span>
                               </ContentTemplate>
                           </telerik:RadButton>
                       </div>
                       <div class="col-md-2">
                           <telerik:RadButton ID="RadButtonDeletePublication" runat="server" RenderMode="Lightweight" ToolTip="<%$ Resources:FacultySites, Delete%>" OnClick="RadButtonDeletePublication_Click" CommandArgument="<%# (DataBinder.GetDataItem(Container) as Idc.FacultySites.Models.Publication).Id %>" OnCommand="RadButtonDeletePublication_Command">
                               <ContentTemplate>
                                   <span class="glyphicon glyphicon-remove"></span>
                               </ContentTemplate>
                               <ConfirmSettings ConfirmText="<%$ Resources:FacultySites, GeneralActionConfirmMessage%>" />
                           </telerik:RadButton>
                       </div>
                       <div class="col-md-8"> </div>
                   </div>
               </div>
           </div>
           <div class="row">
               <div class="col-md-12"> </div>
           </div>               
       </ItemTemplate>
   </telerik:RadListBox>
   </telerik:RadAjaxPanel>

 

2 Answers, 1 is accepted

Sort by
0
Hagai
Top achievements
Rank 1
Veteran
answered on 26 Dec 2019, 11:58 AM

I figured how to solved it as i had some javascript inside script tag in page outside and after the radajaxpanel decleration.

so i put that script within a RadCodeBlock control and now its working.

 

Now i have another question as I need to open a rad window when clicking on a button withing my radlistbox item template and to bind data to the controls in side my radwindow what is the correct way to do so?

 

Right now when i bind the data to the controls on the item click event and then I run the following code to open the radwindow

<p>string script = "function f(){$find(\"" + RadWindowEditPublication.ClientID + "\").show(); Sys.Application.remove_load(f);}Sys.Application.add_load(f);";<br>                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", script, true);</p><p></p>

 

I'm getting my rad window open but all the controls are empty.

here is the declarations of my rad window

<telerik:RadWindow ID="RadWindowEditPublication" runat="server" Modal="True" Skin="Bootstrap" AutoSizeBehaviors="Height, Width" Title="<%$ Resources:FacultySites, EditPublication%>" Height="600px" Width="1024px">
        <ContentTemplate>
            <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanelEPW" runat="server" Skin="Bootstrap"></telerik:RadAjaxLoadingPanel>
            <telerik:RadAjaxPanel ID="RadAjaxPanelEditPublication" runat="server" LoadingPanelID="RadAjaxLoadingPanelEPW">
                <%--<p>
                <asp:Literal ID="LiteralUploadPublicationInstructions" runat="server" Text="<%$ Resources:FacultySites, EditPublication%>"></asp:Literal>
            </p>--%>
                <div class="row">
                    <div class="col-md-12">
                        <strong>
                            <asp:Literal runat="server" Text="<%$ Resources:FacultySites, LinkTo%>"></asp:Literal></strong>
                        <br />
                    </div>
                </div>
                <div class="row">
                    <div class="col-md-3">
                        <asp:RadioButton ID="RadioButtonPublicationByLink" ClientIDMode="Static" runat="server" GroupName="PublicationType" Text="<%$ Resources:FacultySites, Site%>" onclick="javascript:enableDisablePublicationFields('RadTextBoxPublicationLink','RadAsyncUploadPublication',false)" CssClass="radio-padding" />
                    </div>
                    <div class="col-md-9">
                        <telerik:RadTextBox ID="RadTextBoxPublicationLink" ClientIDMode="Static" runat="server" InputType="Url" Enabled="false" ValidationText="<%$ Resources:FacultySites, InvalidURL%>" required></telerik:RadTextBox>
                    </div>
                </div>
                <div class="row">
                    <div class="col-md-3">
                        <asp:RadioButton ID="RadioButtonPublicationByFile" ClientIDMode="Static" runat="server" CausesValidation="false" GroupName="PublicationType" Text="<%$ Resources:FacultySites, File%>" onclick="javascript:enableDisablePublicationFields('RadAsyncUploadPublication','RadTextBoxPublicationLink',false)" CssClass="radio-padding" />
                    </div>
                    <div class="col-md-9">
                        <telerik:RadAsyncUpload ID="RadAsyncUploadPublication" ClientIDMode="Static" runat="server" MaxFileInputsCount="1" AllowedFileExtensions="pdf,docx,doc" AllowedMimeTypes="application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/msword,application/pdf" OnClientValidationFailed="validationFailed" PersistConfiguration="True" dir="<%$ Resources:FacultySites, AttrDirValue%>" Enabled="false"></telerik:RadAsyncUpload>
                    </div>
                </div>
                <div class="row">
                    <div class="col-md-3">
                        <asp:RadioButton ID="RadioButtonEmptyPublication" ClientIDMode="Static" runat="server" CausesValidation="false" GroupName="PublicationType" Text="<%$ Resources:FacultySites, NoLink%>" onclick="javascript:enableDisablePublicationFields('RadAsyncUploadPublication','RadTextBoxPublicationLink',true)" CssClass="radio-padding" />
                    </div>
                    <div class="col-md-9">
                          
                    </div>
                </div>
                <p> </p>
                <div class="row">
                    <div class="col-md-3">
                        <strong>
                            <asp:Literal runat="server" Text="<%$ Resources:FacultySites, PublicationDirection%>"></asp:Literal></strong>
                        <br />
                    </div>
                    <div class="col-md-3">
                        <asp:RadioButton ID="RadioButtonAlignRight" ClientIDMode="Static" runat="server" CausesValidation="false" GroupName="Aligndirection" Text="<%$ Resources:FacultySites, Right%>" CssClass="radio-padding" OnCheckedChanged="RadioButtonAlignRight_CheckedChanged" AutoPostBack="true" />
                    </div>
                    <div class="col-md-3">
                        <asp:RadioButton ID="RadioButtonAlignLeft" ClientIDMode="Static" runat="server" CausesValidation="false" GroupName="Aligndirection" Text="<%$ Resources:FacultySites, Left%>" CssClass="radio-padding" OnCheckedChanged="RadioButtonAlignLeft_CheckedChanged" AutoPostBack="true" />
                    </div>
                    <div class="col-md-3"> </div>
                </div>
                <p> </p>
                <div class="row">
                    <div class="col-md-12">
                        <FTB:FreeTextBox ID="FreeTextBoxPublications" runat="server" AllowHtmlMode="false" EnableHtmlMode="false" Height="175"
                            Width="100%" TextDirection="LeftToRight" ButtonSet="OfficeXP" ToolbarLayout=" bulletedlist, numberedlist , Bold, Italic, Underline;|
                                                                            Strikethrough, Superscript, Subscript,
                                                                            RemoveFormat, JustifyLeft, JustifyRight, JustifyCenter, JustifyFull, BulletedList,
                                                                            NumberedList, Indent, Outdent, Cut, Copy;|
                                                                            Paste, Delete, Undo, Redo, Print,StyleMenu, SymbolsMenu, InsertRule, InsertDate,
                                                                            InsertTime; InsertTable, EditTable, InsertTableRowBefore, InsertTableRowAfter, DeleteTableRow, InsertTableColumnBefore, InsertTableColumnAfter, DeleteTableColumn|
                                                                            InsertTextBox, InsertTextArea,InsertRadioButton, InsertCheckBox, InsertDropDownList, InsertButton, SelectAll, EditStyle">
                        </FTB:FreeTextBox>
                    </div>
                </div>
                <div class="row">
                    <div class="col-md-12"> </div>
                </div>
                <div class="pull-right">
                    <asp:HiddenField ID="HiddenFieldEditiablePublicationID" runat="server" />
                    <telerik:RadButton ID="RadButtonUpdatePublication" runat="server" RenderMode="Lightweight" Text="<%$ Resources:FacultySites, SaveClose%>" Primary="true" OnClick="RadButtonUpdatePublication_Click"></telerik:RadButton>
                </div>
            </telerik:RadAjaxPanel>
        </ContentTemplate>
    </telerik:RadWindow>

 

looking forward for help.

 

 

0
Eyup
Telerik team
answered on 31 Dec 2019, 06:38 AM

Hello Hagai,

 

Here are my suggestions for this case:

1. Temporarily remove AJAX and ensure that the whole app and functionality works without AJAX:
https://www.telerik.com/support/kb/aspnet-ajax/ajaxmanager/details/get-more-descriptive-errors-by-disabling-ajax
2. Take out the RadAjaxPanel inside the ContenTemplate and place it above the RadWindow to wrap the entire RadWindow definition.

I hope these steps will help you resolve the issue.

Regards,
Eyup
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
AjaxPanel
Asked by
Hagai
Top achievements
Rank 1
Veteran
Answers by
Hagai
Top achievements
Rank 1
Veteran
Eyup
Telerik team
Share this question
or