Skip to main content
A newer version of this page is available. .
Tab

ASPxCallback Class

A callback control.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v20.2.dll

Declaration

public class ASPxCallback :
    ASPxWebComponent

Remarks

The ASPxCallback control allows you to send callbacks from the client side and then process them both on the server and client sides.

Note

The ASPxCallback control cannot update any visual control on a web page. For this purpose, use the ASPxCallbackPanel control that serves as a container. Use the callback panel to send a callback to the server and update any control within the panel.

Create a Callback Control

Design Time

The ASPxCallback control is available on the DX.20.2: Components toolbox tab in the Microsoft Visual Studio IDE.

Drag the control onto a form and customize the control’s settings, or paste the control markup in the page’s source code.

Note

To properly function, DevExpress controls require that special modules, handlers and options are registered in the the Web.config file. Switch the Microsoft Visual Studio IDE to the Design tab to automatically update the Web.config file with the required DevExpress information.

<dx:ASPxCallback ID="ASPxCallback1" runat="server">
</dx:ASPxCallback>

Run Time

using DevExpress.Web;
...
protected void Page_Load(object sender, EventArgs e)
{
    ASPxCallback callback = new ASPxCallback();
    callback.ID = "ASPxCallback2";
    Page.Form.Controls.Add(callback);

    callback.ClientInstanceName = "cb";
    callback.Callback += new CallbackEventHandler(ASPxCallback_Callback);
}
protected void ASPxCallback_Callback(object source, CallbackEventArgs e)
{
    // your code
}

Client-Side API

Availability

Available by default.

Client object type

ASPxClientCallback

Access name

ASPxCallback.ClientInstanceName

Events

ASPxCallback.ClientSideEvents

Overview

Use the (ASPxClientCallback.PerformCallback) method to send a callback to the server. The (ASPxClientControlBase.InCallback) method allows you to get whether the callback is sent. Handle the (ASPxClientCallback.CallbackComplete) client event or the ASPxCallback.Callback server event to process the callback.

<dx:ASPxCallback ID="ASPxCallback1" runat="server" ClientInstanceName="Callback1"
    OnCallback="ASPxCallback1_Callback">
    <ClientSideEvents CallbackComplete="OnCallbackComplete" />
</dx:ASPxCallback>
protected void ASPxCallback1_Callback(object sender, CallbackEventArgs e) {
    string xpath = string.Format("//items/item[@newsID='{0}']", e.Parameter);
    XmlNode node = XmlDataSource1.GetXmlDocument().SelectSingleNode(xpath);
    if(node != null)
        e.Result = node.Attributes["Description"].Value;
}
function OnCallbackComplete(s, e) {
    var strFeedID = e.parameter.toString();
    var loadingPanel = document.getElementById("lp" + strFeedID);
    var detailsContainer = document.getElementById("details" + strFeedID);
    loadingPanel.style.display = "none";
    detailsContainer.style.display = "";
    detailsContainer.innerHTML = e.result;
}

Concept

The Concept of Callbacks

Online Demo

ASPxCallback - Demo

See Also