UserControl - Callback could not be found

2 posts, 1 answers
  1. Marc
    Marc avatar
    17 posts
    Member since:
    Jan 2013

    Posted 23 May 2013 Link to this post

    Hi,

    I am experiencing the exact problem described in the following thread (http://www.telerik.com/community/forums/aspnet-ajax/combobox/target-for-the-callback-could-not-be-found.aspx)... I am loading a User Control dynamically from the masterpage's code behind and the included Combobox with EnableAutomaticLoadOnDemand = true fails on loading with the message: The target 'XXXXXXXXXXXXXXXXXXX' for the callback could not be found or did not implement ICallbackEventHandler.

    Did you find a solution finally?

    My UC code:
    <telerik:RadAjaxManagerProxy ID="AjaxManagerProxy1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="ProductList">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="ProductList" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManagerProxy>
    <telerik:RadComboBox ID="ProductList" runat="server" DataTextField="Name" EnableAutomaticLoadOnDemand="true" MarkFirstMatch="true" EnableItemCaching="true" Filter="Contains" DataValueField="Id" ShowMoreResultsBox="true" EnableVirtualScrolling="true" ItemsPerRequest="20" Width="350px"></telerik:RadComboBox>

    My UC code behind:
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
                Dim sqlDS As New SqlDataSource
                sqlDS.ConnectionString = connString 'Defined previously
                sqlDS.SelectCommand = sqlQuery 'Defined previously
                ProductList.DataSource = sqlDS
                ProductList.DataBind()
    End Sub

    MasterPage code behind loads the UC with LoadControl. Masterpage also includes RadAjaxManager.

    Thanks.
  2. Answer
    Plamen
    Admin
    Plamen avatar
    3057 posts

    Posted 28 May 2013 Link to this post

    Hello Marc,

     

    The Lead On Demand mechanism, initiate a callback to the server, each time the user types, deletes or simply expands the dropdown. Therefore, you need to make sure that the control is added to the Form's control collection on each postback/callback. You could achieve this, by using a variable stored in the Session, which would indicate if the RadComboBox is already created or not. Thus you would be aware weather to recreate the control. Here is a sample code that shows how such error could be workarounded:

    protected void Page_Load(object sender, EventArgs e)
       {
           if (ViewState["ComboCreated"] != null)
           {
               CreateComboBox();
           }
       }
      
       protected void radbutton1_Click(object sender, EventArgs e)
       {
           CreateComboBox();
       }
      
       private void CreateComboBox()
       {
           RadComboBox RadComboBox1 = new RadComboBox();
           RadComboBox1.EnableLoadOnDemand = true;
           RadComboBox1.ID = "RadComboBox1";
           div1.Controls.Add(RadComboBox1);
           ViewState["ComboCreated"] = true;
       }

    Hope this will explain the issue and be helpful.

    Regards,
    Plamen
    Telerik
    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