What causes this error?

5 posts, 1 answers
  1. troyboy
    troyboy avatar
    9 posts
    Member since:
    Mar 2007

    Posted 22 Nov 2010 Link to this post

    Hi, I am getting the following error in my code:

    Microsoft JScript runtime error: Sys.InvalidOperationException: Could not find UpdatePanel with ID 'RadListView1_ctrl0_Panel1Panel'. If it is being updated dynamically then it must be inside another UpdatePanel.

    Here is the exact code to reproduce it:(press any of the buttons on the pages causes the error)

    <%@ Page Theme="TSC" Language="C#" AutoEventWireup="true" CodeFile="Test2.aspx.cs" Inherits="rq2DN_Test2" %>
      
       
        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      
        <html xmlns="http://www.w3.org/1999/xhtml">
        <head id="Head1" runat="server">
            <title>Test</title>
        </head>
        <body>
        <form id="form1" runat="server">
         
      
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
        </telerik:RadScriptManager>
         
      
        <telerik:RadFormDecorator ID="RadFormDecorator1" runat="server" />
      
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" Runat="server" >
        </telerik:RadAjaxLoadingPanel>
      
        <asp:HiddenField ID="hfCatalogueId" runat="server" />
        <asp:HiddenField ID="hfTemporary" runat="server" />
      
        <asp:Panel ID="ListViewPanel" runat="server">
            <telerik:RadListView ID="RadListView1" runat="server" DataKeyNames="StockNumber" DataSourceID="objCatalogue"
                onitemcreated="RadListView1_ItemCreated">
                <LayoutTemplate>
                    <div class="RadListView RadListView_Default">
                        <div id="itemPlaceholder" runat="server">
                        </div>
                    </div>
                </LayoutTemplate>
                <ItemTemplate>
                    <table>
                        <tr>
                            <td>
                                <asp:Label ID="Label2" runat="server" Text='<%# Bind("StockNumber") %>'></asp:Label>
                            </td>
                            <td rowspan="2" valign="top">
                                <asp:Panel ID="Panel1" runat="server">
                                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("StockNumber") %>'></asp:Label>
                                    <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
                                </asp:Panel>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <asp:Label ID="Label3" runat="server" Text='<%# Bind("StockNumber") %>'></asp:Label>
                            </td>
                        </tr>
                    </table>
                </ItemTemplate>
            </telerik:RadListView>
        </asp:Panel>
      
        <asp:ObjectDataSource ID="objCatalogue" runat="server" OldValuesParameterFormatString="original_{0}"
            SelectMethod="getCatalogueWithShoppingInfo" TypeName="com.srb.rq2.CatalogueDAO"
            EnablePaging="True" SelectCountMethod="getRowCount">
            <SelectParameters>
                <asp:ControlParameter ControlID="hfCatalogueId" PropertyName="Value" Name="catalogueId" Type="Int32"/>
                <asp:ControlParameter ControlID="hfTemporary" PropertyName="Value" Name="searchText" Type="String"/>
            </SelectParameters>
        </asp:ObjectDataSource>
      
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"></telerik:RadAjaxManager>
      
        <telerik:RadAjaxManagerProxy ID="RadAjaxManagerProxy1" runat="server">
        </telerik:RadAjaxManagerProxy>
      
        </form>
    </body>
    </html>

    and here is the code-behind:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Threading;
    using Telerik.Web.UI;
    using com.srb.rq2;
    using com.srb.core.util;
      
    public partial class rq2DN_Test2 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
      
      
            if (!IsPostBack)
            {
                hfCatalogueId.Value = "18";
                hfTemporary.Value = "";
            }
        }
      
        protected void Button1_Click(object sender, EventArgs e)
        {
            Thread.Sleep(2000);
        }
        protected void RadListView1_ItemCreated(object sender, Telerik.Web.UI.RadListViewItemEventArgs e)
        {
            if (e.Item is RadListViewDataItem)
            {
                RadListViewDataItem item = (RadListViewDataItem)e.Item;
                Button button = (Button)e.Item.FindControl("Button1");
                Panel panel = (Panel)e.Item.FindControl("Panel1");
      
      
      
                RadAjaxManagerProxy1.AjaxSettings.AddAjaxSetting(button, panel, RadAjaxLoadingPanel1);
            }
        }
    }
  2. SamJ
    SamJ avatar
    101 posts
    Member since:
    Jul 2008

    Posted 23 Nov 2010 Link to this post

    Hi,

    Try adding the ajax setting in the RadListView PreRender event instead on ItemCreated. In the PreRender event you need to loop through the listview items and use similar code as in the ItemCreated event to add the settings.
    Thus the error you receive should be solved.

    Let me know if this helps.

    SamJ
  3. troyboy
    troyboy avatar
    9 posts
    Member since:
    Mar 2007

    Posted 23 Nov 2010 Link to this post

    I added a prerender event as you suggested instead of the item created and it still fails with the same error :(

    protected void RadListView1_PreRender(object sender, EventArgs e)
    {
        int count = RadListView1.Items.Count;
        foreach (RadListViewDataItem item in RadListView1.Items)
        {
            Button button = (Button)item.FindControl("Button1");
            Panel panel = (Panel)item.FindControl("Panel1");
            RadAjaxManagerProxy1.AjaxSettings.AddAjaxSetting(button, panel, RadAjaxLoadingPanel1);
        }
    }
  4. troyboy
    troyboy avatar
    9 posts
    Member since:
    Mar 2007

    Posted 23 Nov 2010 Link to this post

    Here is the new code to reproduce the error:

    Test2.aspx:
    <%@ Page Theme="TSC" Language="C#" AutoEventWireup="true" CodeFile="Test2.aspx.cs" Inherits="rq2DN_Test2" %> 
        
         
        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
        
        <html xmlns="http://www.w3.org/1999/xhtml"
        <head id="Head1" runat="server"
            <title>Test</title
        </head
        <body
        <form id="form1" runat="server"
           
        
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server"
        </telerik:RadScriptManager
           
        
        <telerik:RadFormDecorator ID="RadFormDecorator1" runat="server"/> 
        
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" Runat="server"
        </telerik:RadAjaxLoadingPanel
        
        <asp:Panel ID="ListViewPanel" runat="server"
            <telerik:RadListView ID="RadListView1" runat="server" 
                DataKeyNames="StockNumber" DataSourceID="objCatalogue"
                onprerender="RadListView1_PreRender"
                <LayoutTemplate
                    <div class="RadListView RadListView_Default"
                        <div id="itemPlaceholder" runat="server"
                        </div
                    </div
                </LayoutTemplate
                <ItemTemplate
                    <table
                        <tr
                            <td
                                <asp:Label ID="Label2" runat="server" Text='<%# Bind("StockNumber") %>'></asp:Label
                            </td
                            <td rowspan="2" valign="top"
                                <asp:Panel ID="Panel1" runat="server"
                                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("StockNumber") %>'></asp:Label
                                    <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click"/> 
                                </asp:Panel
                            </td
                        </tr
                        <tr
                            <td
                                <asp:Label ID="Label3" runat="server" Text='<%# Bind("StockNumber") %>'></asp:Label
                            </td
                        </tr
                    </table
                </ItemTemplate
            </telerik:RadListView
        </asp:Panel
        
        <asp:ObjectDataSource ID="objCatalogue" runat="server" SelectMethod="getData" TypeName="com.srb.rq2.CatalogueTestDAO"/>
        
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"></telerik:RadAjaxManager>
        
        <telerik:RadAjaxManagerProxy ID="RadAjaxManagerProxy1" runat="server"
        </telerik:RadAjaxManagerProxy
        
        </form
    </body
    </html>

    The code-behind:
    using System; 
    using System.Collections.Generic; 
    using System.Linq; 
    using System.Web; 
    using System.Web.UI; 
    using System.Web.UI.WebControls; 
    using System.Threading; 
    using Telerik.Web.UI; 
    using com.srb.rq2; 
    using com.srb.core.util; 
        
    public partial class rq2DN_Test2 : System.Web.UI.Page 
        protected void Page_Load(object sender, EventArgs e) 
        
        
        
        protected void Button1_Click(object sender, EventArgs e) 
        
            Thread.Sleep(2000); 
        
        protected void RadListView1_PreRender(object sender, EventArgs e)
        {
            int count = RadListView1.Items.Count;
            foreach (RadListViewDataItem item in RadListView1.Items)
            {
                Button button = (Button)item.FindControl("Button1");
                Panel panel = (Panel)item.FindControl("Panel1");
                RadAjaxManagerProxy1.AjaxSettings.AddAjaxSetting(button, panel, RadAjaxLoadingPanel1);
            }
        }
    }

    And finally the object data source (CatalogueTestDAO.cs)
    using System.Collections.Generic;
      
    namespace com.srb.rq2
    {
        public class CatalogueTestDAO
        {
            public List<MyData> getData()
            {
                List<MyData> data = new List<MyData>();
                for (int index = 0; index < 10; index++)
                {
                    data.Add(new MyData()
                    {
                        StockNumber = "abc"
                    });
                }
                return data;
            }
        } // class
      
        public class MyData
        {
            public string StockNumber { get; set; }
        }
    } // namespace
  5. Answer
    Radoslav
    Admin
    Radoslav avatar
    1566 posts

    Posted 25 Nov 2010 Link to this post

    Hello Troyboy,

    Could you please try removing the RadAjaxManagerProxy control and add ajax settings to the RadAjaxManager1:
    protected void RadListView1_PreRender(object sender, EventArgs e)
    {
        int count = RadListView1.Items.Count;
        foreach (RadListViewDataItem item in RadListView1.Items)
        {
            Button button = (Button)item.FindControl("Button1");
            Panel panel = (Panel)item.FindControl("Panel1");
            RadAjaxManager1.AjaxSettings.AddAjaxSetting(button, panel, RadAjaxLoadingPanel1);
        }
    }

    Additionally please check out the following articles which explains how to use the RadAjaxManager and RadAjaxManagerProxy controls:
    http://www.telerik.com/help/aspnet-ajax/ajxusercontrols.html
    http://www.telerik.com/help/aspnet-ajax/ajxajaxmasterpage.html
    http://www.telerik.com/help/aspnet-ajax/ajxajaxifyparticulartemplatedgridviewbuttons.html

    I hope this helps.

    Greetings,
    Radoslav
    the Telerik team
    Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Back to Top