Skip to main content
All docs
V23.2

The target 'X' for the callback could not be found or did not implement ICallbackEventHandler

  • 2 minutes to read

Error Description

This error occurs for a parent control or its child controls if the parent control is created at runtime.

Solution

Follow the steps below when you create a control/WebUserControl at runtime:

  1. Use a control’s constructor or call the LoadControl method with a virtual path to a web user control (*.acsx file) as a parameter to create/load a control or WebUserControl.

  2. Specify the control’s ID property.

    All child controls in a naming container have IDs based on the ID of this container. For example, if an instance of the ASPxDataView with the static ID “ASPxDataView1” is a part of a user control (DataViewUserControl.ascx), its result ID is DataViewUserControl_ASPxDataView1. If a control has no static ID, it is generated dynamically on each request.

  3. Specify the control’s SkinID and EnableTheming properties (optional).

  4. Attach event handlers (if required).

  5. Insert the control into the control hierarchy.

    You should restore the control with the same settings in the Page_Init event when you modify the control hierarchy.

  6. Specify the control’s properties.

  7. Bind the control (for data-aware controls).

protected void Page_Init(object sender, EventArgs e) {  
    if (Session["Loaded"] != null) {  
        LoadUserControl();  
    }  
}  

protected void ASPxCallbackPanel1_Callback(object source, DevExpress.Web.ASPxClasses.CallbackEventArgsBase e) {  
    if (e.Parameter == "Show") {  
        LoadUserControl();  
        Session["Loaded"] = true;  
    }  
    else {  
        UnloadUserControl();  
        Session.Remove("Loaded");  
    }  
}  

protected void LoadUserControl() {  
    Control control = LoadControl("~/DataViewUserControl.ascx");  
    control.ID = "uc";  
    ASPxCallbackPanel1.Controls.Add(control);  
}  

protected void UnloadUserControl() {  
    ASPxCallbackPanel1.Controls.Clear();  
}  

See also