Callback could not be found

2 posts, 0 answers
  1. Mike
    Mike avatar
    6 posts
    Member since:
    Sep 2012

    Posted 25 Sep 2012 Link to this post

    I am trying to implement a ComboBox inside a ToolTip which consists of a user control.  When I click in the combox, I get the following error:

    The target 'ctl100$ctl100$PageContent$PageContent$ctl11$drpdwnEmail1' for the callback could not be found or did not implement ICallbackEventHandler

    I am thinking it is because the user control that contains the above ComboBox is added dynamically, and when the OnItemsRequested handler is fired on the combobox, it no longer exists.  The solutions I have found on this site say to make sure to add the control each time OnPageLoad.  However, this isn't realistic because parameters are passed to the control depending on which row of a Repeater we are in....

    MyPage.aspx: 
    <telerik:RadToolTipManager ID="RadToolTipManager1" OffsetY="-1" HideEvent="ManualClose" ShowEvent="OnClick" Skin="Office2010Silver" Width="500" Height="175" runat="server" OnAjaxUpdate="OnAjaxUpdate" RelativeTo="Element" Position="MiddleLeft" />
      
    <asp:Repeater ID="rptrMyRepeater" runat="server" OnItemDataBound="myRepeater_OnItemDataBound">
       <ItemTemplate>
          <div>
             <asp:LinkButton runat="server" ID="btnEmailAttachment" Text="Open Popup" OnClientClick="return false;" />
          </div>
       </ItemTemplate>
    </asp:Repeater>


    MyPage.aspx.cs

    protected void myRepeater_OnItemDataBound(object o, RepeaterItemEventArgs e)
    {
       if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
       {
          RadToolTipManager1.TargetControls.Add(((LinkButton)e.Item.FindControl("btnEmailAttachment")).ClientID, Convert.ToString(DataBinder.Eval(e.Item.DataItem, "RequestID")), true);
       }
    }
      
    protected void OnAjaxUpdate(object sender, ToolTipUpdateEventArgs args)
    {
        int requestID = Convert.ToInt32(args.Value);
      
        Control ctrl = Page.LoadControl("EmailBox.ascx");
        args.UpdatePanel.ContentTemplateContainer.Controls.Add(ctrl);
        CollateralCentral_EmailBox emailBox = (CollateralCentral_EmailBox)ctrl;
        emailBox.RequestID = requestID;
    }


    EmailBox.ascx

    <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server">
            <telerik:RadComboBox 
                           ID="drpdwnEmail1" 
                           runat="server" 
                           Width="350px" 
                           Height="140px" 
                           EnableLoadOnDemand="True" 
                           OnItemsRequested="RadComboBox1_ItemsRequested" />
    </telerik:RadAjaxPanel>

     

     EmailBox.ascx.cs

    protected void RadComboBox1_ItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e)
    {
        drpdwnEmail1.Items.Clear();
        if (e.Text.Trim().Length > 2) // make them type at least 3 letters
        {
                DataTable dt = GetDataTable();
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    drpdwnEmail1.Items.Add(new RadComboBoxItem((string)dt.Rows[i]["Email_addr"], Convert.ToString(dt.Rows[i]["Email_addr"])));
                }
                dt.Dispose();
         }
    }

    I am not sure in this example how to get past this error - I need to load the control in the manner I am loading it and can't do it each time a postback happens, and I need to populate the email dropdown server-side because there are about 100,000 email addresses so I want them to start typing before they see anything...

    Any help would be greatly appreciated!!!

  2. Marin Bratanov
    Admin
    Marin Bratanov avatar
    4630 posts

    Posted 28 Sep 2012 Link to this post

    Hello Mike,

    This case is extremely complex, because it contains a lot of dynamic controls and nests two Load-on-demand scenarios:
    - the RadToolTipManager loads controls via AJAX which is inherently a complex case
    - you have inside a control that invokes client callbacks which go through some of the page lifecycle, but not through the entire and thus they do not invoke the reloading of the content in the tooltip manager's update panel

    I am logging this scenario for research in our database and you can monitor its progress, vote for it and leave a comment in this URL. I have also updated your Telerik points for helping us find this scenario.


    Regards,
    Marin Bratanov
    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.
Back to Top