[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Report and Dashboard Server
[Collapse]eXpressApp Framework
 [Expand]Getting Started
 [Expand]Design-Time Features
 [Collapse]Task-Based Help
  [Expand]Business Model Design
  [Expand]Application Model
  [Expand]List Editors
  [Expand]Property Editors
  [Expand]Scheduler and Notifications
  [Collapse]Miscellaneous UI Customizations
    How to: Add a Button to a Detail View Using Custom View Item
    How to: Add an XAF Mobile Custom Module
    How to: Adjust the Size and Style of Pop-up Dialogs (ASP.NET)
    How to: Adjust the Windows' Size and Style
    How to: Change an Application Logo and Info
    How to: Create a Custom Control Detail Item
    How to: Customize a Window Caption
    How to: Customize ASP.NET Layout Elements Using Custom CSS Classes
    How to: Customize Export Options of the Printing System
    How to: Customize the Conditional Appearance Module Behavior
    How to: Customize Window Status Messages (WinForms)
    How to: Enable High DPI Support in a WinForms Application
    How to: Implement a Custom Messaging Class
    How to: Include an Action to a Detail View Layout
    How to: Raise XAF Callbacks from Client-Side Events and Process these Callbacks on Server
    How to: Set Images and Captions for Enumeration Values
    How to: Show a Custom Window with an Embedded XAF View
    How to: Show a Custom Windows Form
    How to: Use a Custom Plugin in a Mobile Application
    How to: Use a Custom Splash Screen
    How to: Use a DevExtreme Chart in a Mobile Application
    How to: Use Custom Themes in ASP.NET Applications
  Frequently Asked Questions (FAQ)
 [Expand]API Reference
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
This documentation page describes implementations made in our v17.2 release cycle. To learn about functionality shipping with v18.1, navigate to our updated help file experience at docs.devexpress.com. Learn More

How to: Raise XAF Callbacks from Client-Side Events and Process these Callbacks on Server

This topic describes how to raise XAF callbacks from the client-side events and process these events on the server. This can be useful if a default control callback is not suitable and you need to refresh all page markups or show a popup window.

This example illustrates how to show a list of underlying persistent objects when the Pivot Grid cell is clicked using the XafCallbackManager class and its two methods: GetScript and RegisterHandler. You can use a similar approach with any other web control.

Show Me

A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=E4087.

Follow the steps below.

  • In the ASP.NET module project, create a ViewController and implement the CallbackManager property which returns the XafCallbackManager object.

  • Override the OnViewControlsCreated method, access the ASPxPivotGrid control and register a new script for the client-side ASPxClientPivotGrid.CellClick event. To create the script, use the XafCallbackManager.GetScript method with the following parameters:

    Parameter Description
    handlerId The registered handler's identifier. The value must be unique for each handler instance. You can use the Guid.NewGuid or Object.GetHashCode methods to create a unique handlerId value.
    parameters A string value which is passed from the client side when the XAF callback is called. In this example, the cell's ColumnIndex and RowIndex values are passed. However, you can pass an empty string if parameters are not required.

    Use the ClientSideEventsHelper.AssignClientHandlerSafe method to register the client-side event handler to avoid replacing the existing scripts that handle this client-side event.

  • Implement the IXafCallbackHandler interface in your Controller. Register an XAF callback handler by calling the XafCallbackManager.RegisterHandler method in the OnViewControlCreated method. The first parameter is the handlerId variable that was created earlier. The second parameter is an IXafCallbackHandler object which is the current Controller instance in this example.


    Always register an XAF callback handler in the OnViewControlsCreated method, because this method is called before processing each page callback.

  • The IXafCallbackHandler.ProcessAction method body is empty in the previous snippet. You should add the server-side code that is executed when the server receives the XAF callback.

    In this example, the ProcessAction method obtains the clicked cell's column and row indexes from the passed parameters, retrieves the records that are used to calculate this cell summary, and displays these records in the List View.

Is this topic helpful?​​​​​​​