Skip to main content
Tab

ASPxCallback Class

A non-visual component that allows you to make a round trip to the server (send a custom callback request) and perform server-side actions. The component cannot update other controls in a callback.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v24.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.

Run Demo

Create a Callback Control

Design Time

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

Callback Control

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

<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
}

Note

DevExpress controls require that you register special modules, handlers, and options in the Web.config file. You can change this file or switch to the Design tab in the Microsoft Visual Studio IDE to automatically update the Web.config file. Note that this information is automatically registered if you use the DevExpress Template Gallery to create a project.

Client-Side API

Availability

Available by default.

Client object type

ASPxClientCallback

Access name

ASPxCallback.ClientInstanceName

Events

ASPxCallback.ClientSideEvents

Overview

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

You can use the JSProperties property to send information from the server to the client.

<dx:ASPxButton ID="ASPxButton1" runat="server" Text="Get time from server" AutoPostBack="False">
    <ClientSideEvents Click="function(s, e) { callbackControl.PerformCallback(); }" />
</dx:ASPxButton>

<dx:ASPxCallback ID="ASPxCallback1" runat="server" ClientInstanceName="callbackControl" 
    OnCallback="ASPxCallback1_Callback">
    <ClientSideEvents CallbackComplete="function(s, e) {
        document.getElementById('editorContainer').innerHTML = s.cpTextBox1;
        textBox2.SetText(s.cpTime);
    }" />
</dx:ASPxCallback>

<table id="formContainer">
    <tr>
        <td id="editorContainer">
            <asp:TextBox ID="TextBox1" runat="server" Width="200px" ></asp:TextBox>
        </td>
        <td>
            <dx:ASPxTextBox ID="ASPxTextBox1" runat="server" ClientInstanceName="textBox2" Width="200px" />
        </td>
    </tr>
</table>
protected void ASPxCallback1_Callback(object source, DevExpress.Web.ASPxCallback.CallbackEventArgs e){
    ASPxCallback callbackControl = source as ASPxCallback;
    string time = DateTime.Now.ToString("T");
    TextBox1.Text = time;
    callbackControl.JSProperties["cpTextBox1"] = ASPxCallback.GetRenderResult(TextBox1);
    callbackControl.JSProperties["cpTime"] = time;
}
See Also